Commit 44af5fd
committed
fix: ClientContext(sdkKey) test ctor generates a single instance id (SDK-2356)
Previously the public single-arg `ClientContext(String sdkKey)` test-convenience
constructor produced an internally inconsistent state: `defaultHttp(sdkKey)`
built an HttpConfiguration whose default headers embedded one auto-generated
UUID (via the inner minimalContext), and the outer delegated 8-arg constructor
auto-generated a separate UUID for `this.instanceId`. As a result,
`context.getInstanceId()` and `context.getHttp().getDefaultHeaders()` returned
different values for `X-LaunchDarkly-Instance-Id` -- so consumer code that
read the instance id via the getter would see a different identifier than the
SDK actually placed on outbound requests.
Generate the UUID once in a new private delegating constructor and thread it
both into `defaultHttp(sdkKey, instanceId)` (so the headers carry it) and
into the explicit instanceId argument of the 9-arg constructor (so the
accessor returns the same value).
Added a regression test in ClientContextImplTest that asserts these two
accessors agree.1 parent 30cf64b commit 44af5fd
2 files changed
Lines changed: 52 additions & 9 deletions
File tree
- lib/sdk/server/src
- main/java/com/launchdarkly/sdk/server/subsystems
- test/java/com/launchdarkly/sdk/server
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
135 | | - | |
| 145 | + | |
136 | 146 | | |
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
140 | | - | |
| 150 | + | |
| 151 | + | |
141 | 152 | | |
142 | 153 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
146 | 158 | | |
147 | 159 | | |
148 | 160 | | |
| |||
Lines changed: 35 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
| 104 | + | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
110 | 141 | | |
0 commit comments