This repository was archived by the owner on May 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
main/java/com/launchdarkly/sdk
test/java/com/launchdarkly/sdk Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -380,8 +380,8 @@ ContextBuilder copyFrom(LDContext context) {
380
380
anonymous = context .isAnonymous ();
381
381
attributes = context .attributes ;
382
382
privateAttributes = context .privateAttributes ;
383
- copyOnWriteAttributes = true ;
384
- copyOnWritePrivateAttributes = true ;
383
+ copyOnWriteAttributes = context . attributes != null ;
384
+ copyOnWritePrivateAttributes = context . privateAttributes != null ;
385
385
return this ;
386
386
}
387
387
Original file line number Diff line number Diff line change 10
10
import static org .hamcrest .Matchers .emptyIterable ;
11
11
import static org .hamcrest .Matchers .equalTo ;
12
12
import static org .hamcrest .Matchers .is ;
13
+ import static org .hamcrest .Matchers .notNullValue ;
13
14
import static org .hamcrest .Matchers .nullValue ;
14
15
15
16
@ SuppressWarnings ("javadoc" )
@@ -131,4 +132,14 @@ public void builderFromContext() {
131
132
}
132
133
}
133
134
}
135
+
136
+ @ Test
137
+ public void doesNotThrowNPEWhenReusingContext () {
138
+ LDContext initialContext = LDContext .builder ("123456" ).build ();
139
+ LDContext downstreamContext = LDContext .builderFromContext (initialContext )
140
+ .set ("some_attribute" , "someValue" )
141
+ .build ();
142
+
143
+ assertThat (downstreamContext , notNullValue ());
144
+ }
134
145
}
You can’t perform that action at this time.
0 commit comments