Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

prepare 5.6.0 release #241

Merged
merged 994 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
994 commits
Select commit Hold shift + click to select a range
ffda80a
Merge branch '5.x' into eb/ch25268/flag-tracker
eli-darkly May 20, 2020
223e038
fix merge conflict
eli-darkly May 20, 2020
4cdb376
preprocess various things to speed up evaluations
eli-darkly May 22, 2020
d97a5bc
(5.0) don't bother creating event objects if they won't be sent
eli-darkly May 22, 2020
b56d541
cleaner EventFactory design
eli-darkly May 22, 2020
7515cf8
add test coverage step to CI
eli-darkly May 22, 2020
6132374
add test coverage reporting + improve DefaultEventProcessor tests
eli-darkly May 22, 2020
436ec07
clarify meaning of "events" in javadoc comment
eli-darkly May 22, 2020
d50f669
Merge pull request #234 from launchdarkly/eb/ch25268/flag-tracker
eli-darkly May 22, 2020
631d872
note about benchmarks in CONTRIBUTING
eli-darkly May 22, 2020
a1de46c
rm unused
eli-darkly May 23, 2020
5a1e237
Merge branch '5.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
5e19ff6
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
6565ccc
formatting
eli-darkly May 23, 2020
2a8a284
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
87163c7
use JMH average time mode, not throughput
eli-darkly May 23, 2020
0358ae9
measure in nanoseconds
eli-darkly May 23, 2020
035ff29
fix import
eli-darkly May 23, 2020
0946574
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
4f8273f
move benchmark code to 5.0-like packages for easier cross-comparison
eli-darkly May 23, 2020
6f08081
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
c84cda9
move test data generation out of benchmarks
eli-darkly May 23, 2020
846976c
more configuration tweaks
eli-darkly May 23, 2020
338947c
show more benchmark output
eli-darkly May 23, 2020
db5dc8c
show more benchmark output
eli-darkly May 23, 2020
37e88c6
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
a45bcd9
fix event benchmark synchronization
eli-darkly May 23, 2020
080c599
add jmhReport HTML output
eli-darkly May 23, 2020
d80d245
fix report step
eli-darkly May 23, 2020
4832b76
fix synchronization again
eli-darkly May 23, 2020
2bd5a37
fix event benchmarks so they don't test the construction of the input…
eli-darkly May 23, 2020
0815938
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-4…
eli-darkly May 23, 2020
0cefb4e
fix data file name
eli-darkly May 23, 2020
e2be6e9
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
c52418f
Merge branch 'eb/ch76240/benchmarks-4.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 23, 2020
d184426
Merge branch '5.x' into eb/ch77594/coverage
eli-darkly May 23, 2020
58d1e12
Merge branch '5.x' into eb/ch77442/preprocessing
eli-darkly May 23, 2020
f6961fa
Merge branch 'eb/ch77442/preprocessing' into eb/ch77571/no-events
eli-darkly May 23, 2020
4c47222
Merge branch 'eb/ch77571/no-events' into eb/ch77594/coverage
eli-darkly May 23, 2020
26575df
CI fix (always store test results)
eli-darkly May 23, 2020
1986569
improve test coverage of low-level eval logic to >99%
eli-darkly May 23, 2020
e6e37a5
revert change to flush payload queue behavior
eli-darkly May 23, 2020
ab43703
avoid test race condition
eli-darkly May 23, 2020
d264569
Merge branch 'eb/ch77594/coverage' into eb/ch77594/coverage-2-eval
eli-darkly May 23, 2020
a9b6c81
add test coverage reporting
eli-darkly May 23, 2020
38a4922
CI fix
eli-darkly May 23, 2020
4e3eee3
CI fix
eli-darkly May 23, 2020
051a9d5
Merge branch 'eb/ch77594/coverage-0' into eb/ch77594/coverage-1-events
eli-darkly May 23, 2020
4b85a3f
more event test improvements
eli-darkly May 23, 2020
b898d81
misc cleanup + test improvements
eli-darkly May 23, 2020
ca2e196
Merge branch 'eb/ch77594/coverage-1-events' into eb/ch77594/coverage-…
eli-darkly May 23, 2020
60046ef
misc cleanup + test improvements
eli-darkly May 23, 2020
0f898fa
make intVariation and doubleVariation non-nullable
eli-darkly May 23, 2020
3b0e95b
(5.0) don't use jar magic to find out our own version string
eli-darkly May 23, 2020
f6b7ff2
fix test
eli-darkly May 23, 2020
3fb019f
Merge branch 'eb/ch77594-ch77639/coverage-3-client' into eb/ch77640/v…
eli-darkly May 23, 2020
b3f313c
make intVariation and doubleVariation non-nullable
eli-darkly May 23, 2020
38dacc8
Merge branch 'eb/ch77639/int-double-non-null' into eb/ch77640/version…
eli-darkly May 23, 2020
472dfc7
better unit test coverage of LDClient and FeatureFlagsState
eli-darkly May 23, 2020
3ccd7cb
test coverage improvements + minor fixes
eli-darkly May 24, 2020
7c75b3a
better temp file handling in file data source tests
eli-darkly May 24, 2020
8da3e27
revert file data source implementation change for now
eli-darkly May 24, 2020
306797e
revert unnecessary change
eli-darkly May 24, 2020
e07643f
comment about file watching on Mac
eli-darkly May 24, 2020
1d57156
add slight delay to avoid timing-dependent test flakiness
eli-darkly May 26, 2020
3fad450
test fixes/comments
eli-darkly May 26, 2020
07bb8f5
(5.0) use simpler and more stable logger names
eli-darkly May 26, 2020
2d0628d
better instructions
eli-darkly May 27, 2020
427a87e
more convenient way to set EventSource logger name
eli-darkly May 27, 2020
a89504e
(5.0) add HTTP default headers method + some component refactoring
eli-darkly May 28, 2020
6ce1d8a
don't need to pass the whole config object to describeConfiguration()
eli-darkly May 28, 2020
5d54f0a
simplify test logic for HTTP headers
eli-darkly May 28, 2020
29cf2d7
Merge pull request #236 from launchdarkly/eb/ch77442/preprocessing
eli-darkly May 28, 2020
e336c92
Merge pull request #237 from launchdarkly/eb/ch77571/no-events
eli-darkly May 28, 2020
86050fb
Merge pull request #240 from launchdarkly/eb/ch77594/coverage-0
eli-darkly May 28, 2020
ec01e5b
Merge branch '5.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 28, 2020
c36c6f3
Merge pull request #241 from launchdarkly/eb/ch77594/coverage-1-events
eli-darkly May 29, 2020
bd2162e
Merge pull request #242 from launchdarkly/eb/ch77594/coverage-2-eval
eli-darkly May 29, 2020
daf04c4
Merge pull request #243 from launchdarkly/eb/ch77639/int-double-non-null
eli-darkly May 29, 2020
2719973
Merge pull request #244 from launchdarkly/eb/ch77640/version-string
eli-darkly May 29, 2020
8b24c81
(5.0) final test coverage improvements, for now, with enforcement
eli-darkly May 29, 2020
55f14d1
re-simplify DataBuilder
eli-darkly May 29, 2020
3df7da4
increase timeouts
eli-darkly May 29, 2020
6fc2a7a
misc fixes
eli-darkly May 29, 2020
8b27de5
rm unnecessary override
eli-darkly May 29, 2020
262eb19
Merge branch '5.x' into eb/ch76240/benchmarks-5.x
eli-darkly May 29, 2020
43778a3
indents
eli-darkly May 29, 2020
128b8cc
Merge pull request #245 from launchdarkly/eb/ch77594/coverage-3-client
eli-darkly May 29, 2020
b959c6c
Merge pull request #238 from launchdarkly/eb/ch76240/benchmarks-4.x
eli-darkly May 29, 2020
279ccd5
Merge pull request #239 from launchdarkly/eb/ch76240/benchmarks-5.x
eli-darkly May 29, 2020
6ddb11b
Merge branch 'master' into 5.x
eli-darkly May 29, 2020
37fbfe5
Merge branch '5.x' into eb/ch76203/logger-names
eli-darkly May 29, 2020
fc3d40e
Merge branch '5.x' into eb/ch77594/coverage-4-misc
eli-darkly May 29, 2020
4df1c40
Merge branch 'eb/ch77594/coverage-4-misc' into eb/ch78049/http-headers
eli-darkly May 29, 2020
dbe962f
update benchmark code for API change
eli-darkly May 29, 2020
8b74838
Merge branch 'eb/ch78049/http-headers' into eb/ch77594/coverage-5-misc
eli-darkly May 29, 2020
4b00cde
Merge pull request #246 from launchdarkly/eb/ch77594/coverage-4-misc
eli-darkly May 29, 2020
73062ca
support loading file data from a classpath resource
eli-darkly May 30, 2020
f02f835
update metadata so Releaser knows about 4.x branch
eli-darkly May 30, 2020
9dfc1be
Merge branch '4.x' into 5.x
eli-darkly May 30, 2020
4a3a7fb
minor test fixes
eli-darkly May 30, 2020
0fbd4b0
make class final
eli-darkly May 30, 2020
91941fa
rm beta changelog items
eli-darkly May 30, 2020
851c53b
Merge branch 'eb/debugging'
eli-darkly May 30, 2020
4dd0822
test data source
eli-darkly Jun 1, 2020
907882d
more info about coverage in CONTRIBUTING.md
eli-darkly Jun 1, 2020
7165ca4
Merge pull request #248 from launchdarkly/eb/ch78049/http-headers
eli-darkly Jun 1, 2020
79d11bf
Merge branch 'master' into eb/ch76203/logger-names
eli-darkly Jun 2, 2020
234e905
Merge pull request #247 from launchdarkly/eb/ch76203/logger-names
eli-darkly Jun 2, 2020
75630d0
Merge branch 'master' into eb/ch77594/coverage-5-misc
eli-darkly Jun 2, 2020
1eabb73
Merge branch 'eb/ch77594/coverage-5-misc' into eb/ch76824/classpath-file
eli-darkly Jun 2, 2020
01df1f3
Merge pull request #249 from launchdarkly/eb/ch77594/coverage-5-misc
eli-darkly Jun 2, 2020
ff3d3d1
Merge pull request #250 from launchdarkly/eb/ch76824/classpath-file
eli-darkly Jun 2, 2020
d219b44
Merge branch 'master' into eb/ch78216/test-data
eli-darkly Jun 2, 2020
fa2b39c
misc fixes/tests
eli-darkly Jun 2, 2020
705d25b
use java-sdk-common 1.0.0
eli-darkly Jun 2, 2020
2a44530
use okhttp-eventsource 2.3.0
eli-darkly Jun 2, 2020
9d23a88
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Jun 2, 2020
ddd886a
use okhttp-eventsource 2.3.1 for thread fix
eli-darkly Jun 18, 2020
6374424
Merge pull request #252 from launchdarkly/eb/ch80009/eventsource-thread
eli-darkly Jun 19, 2020
6fb600d
fix flaky tests due to change in EventSource error reporting
eli-darkly Jun 19, 2020
e22d43f
Merge pull request #253 from launchdarkly/eb/ch80009/flaky-test
eli-darkly Jun 19, 2020
8642c8b
merge from public after release
LaunchDarklyCI Jun 19, 2020
8873f44
remove support for indirect put and indirect patch
eli-darkly Jun 23, 2020
9a034e2
Merge pull request #254 from launchdarkly/eb/ch80666/no-indirect-patch
eli-darkly Jun 23, 2020
0293f58
fix typo in javadoc example code
eli-darkly Jun 24, 2020
8a08fc7
Merge pull request #255 from launchdarkly/eb/ch80837/javadoc-typo
eli-darkly Jun 24, 2020
4ad9351
clean up polling logic, fix status updating after an outage, don't re…
eli-darkly Jun 25, 2020
f14119a
merge from public after release
LaunchDarklyCI Jun 25, 2020
d41ae6c
slightly change semantics of boolean setters, improve tests, misc cle…
eli-darkly Aug 4, 2020
378b8e8
avoid NPEs if LDUser was deserialized by Gson (#257)
eli-darkly Aug 4, 2020
4836ea3
fix release metadata
eli-darkly Aug 5, 2020
96e58e7
prepare 4.14.1 release (#200)
LaunchDarklyCI Aug 5, 2020
22149a9
Releasing version 4.14.1
LaunchDarklyCI Aug 5, 2020
2d0d5cd
merge from public after release
LaunchDarklyCI Aug 5, 2020
ef8a801
Merge branch '4.x'
eli-darkly Aug 5, 2020
8825a48
exclude Kotlin metadata from jar + fix misc Gradle problems
eli-darkly Aug 18, 2020
ae46e03
Merge pull request #258 from launchdarkly/eb/ch87032/kotlin-symbols
eli-darkly Aug 18, 2020
b7ce928
merge from public after release
LaunchDarklyCI Aug 19, 2020
b32abc3
update CI and Gradle to test with newer JDKs (#259)
eli-darkly Aug 24, 2020
eefc460
update okhttp to 3.14.9 (fixes incompatibility with OpenJDK 8.0.252)
eli-darkly Aug 31, 2020
87120a4
Merge pull request #260 from launchdarkly/eb/ch88298/okhttp-update-4.x
eli-darkly Sep 1, 2020
0403392
prepare 4.14.2 release (#205)
LaunchDarklyCI Sep 1, 2020
2daeb92
Releasing version 4.14.2
LaunchDarklyCI Sep 1, 2020
7c09c6a
merge from public after release
LaunchDarklyCI Sep 1, 2020
7a9772c
Merge branch '4.x'
eli-darkly Sep 1, 2020
f3f01ec
update okhttp to 4.8.1 (fixes incompatibility with OpenJDK 8.0.252)
eli-darkly Sep 1, 2020
7025ae7
Merge pull request #261 from launchdarkly/eb/ch88298/okhttp-update-5.x
eli-darkly Sep 1, 2020
d1e311e
merge from public after release
LaunchDarklyCI Sep 1, 2020
f5a8555
gitignore
eli-darkly Sep 1, 2020
52c36be
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
gwhelanLD Sep 3, 2020
9fe8f5b
merge from public after release
LaunchDarklyCI Sep 3, 2020
ac9bdb1
Bump SnakeYAML from 1.19 to 1.26 to address CVE-2017-18640
ssrm Sep 3, 2020
d1e0637
Merge pull request #262 from launchdarkly/eb/ch88108/snakeyaml-update
eli-darkly Sep 3, 2020
4f8f980
prepare 4.14.3 release (#209)
LaunchDarklyCI Sep 3, 2020
a6777a8
Releasing version 4.14.3
LaunchDarklyCI Sep 3, 2020
89954b5
merge from public after release
LaunchDarklyCI Sep 3, 2020
a83942e
Merge branch '4.x'
eli-darkly Sep 3, 2020
326e8e1
Merge branch 'master' into eb/ch78216/test-data
eli-darkly Sep 4, 2020
b800f23
comments
eli-darkly Sep 4, 2020
7cb20cd
Merge pull request #251 from launchdarkly/eb/ch78216/test-data
eli-darkly Sep 4, 2020
06fdd3e
only log initialization message once in polling mode
eli-darkly Sep 4, 2020
03e2ad8
Merge pull request #263 from launchdarkly/eb/ch88859/polling-logging
eli-darkly Sep 4, 2020
a448abc
merge from public after release
LaunchDarklyCI Sep 4, 2020
078fe16
[ch89935] Correct some logging call format strings (#264)
gwhelanLD Sep 17, 2020
136eb1b
[ch90109] Remove outdated trackMetric comment from before service sup…
gwhelanLD Sep 18, 2020
889a1c6
Fix compatibility with Java 7.
gwhelanLD Sep 25, 2020
67dea95
Remove import that is no longer used.
gwhelanLD Sep 25, 2020
402b8fe
Merge pull request #266 from launchdarkly/gw/ch90182/fix-java-7-compat
eli-darkly Sep 28, 2020
ee5e212
add Java 7 build (#267)
eli-darkly Sep 28, 2020
cd60e6d
prepare 4.14.4 release (#214)
LaunchDarklyCI Sep 28, 2020
424c7d5
Releasing version 4.14.4
LaunchDarklyCI Sep 28, 2020
72ac981
merge from public after release
LaunchDarklyCI Sep 28, 2020
0113451
add and use getSocketFactory
hroederld Sep 28, 2020
346f655
alignment
hroederld Sep 28, 2020
305f555
add socketFactory to builder
hroederld Sep 28, 2020
7c2eea8
test socket factory builder
hroederld Sep 28, 2020
7f1d8c8
Merge branch '4.x'
eli-darkly Sep 28, 2020
8b51b95
preserve dummy CI config file when pushing to gh-pages (#271)
eli-darkly Sep 30, 2020
f6ae98e
fix concatenation when base URI has a context path (#270)
eli-darkly Oct 1, 2020
b33e5bf
fix shaded jar builds to exclude Jackson classes and not modify Jacks…
eli-darkly Oct 1, 2020
e4ba1cd
merge from public after release
LaunchDarklyCI Oct 1, 2020
18af928
add test httpClientCanUseCustomSocketFactory for DefaultFeatureRequestor
hroederld Oct 7, 2020
fa90fbf
add httpClientCanUseCustomSocketFactory() test for DefaultEventSender…
hroederld Oct 7, 2020
a0b7894
add httpClientCanUseCustomSocketFactory() test to StreamProcessorTest
hroederld Oct 7, 2020
9aeeaaa
merge in master and fix conflict
hroederld Oct 7, 2020
86a601e
pass URI to in customSocketFactory event test
hroederld Oct 9, 2020
ad21f51
[ch90672] Add socketFactory support to SDK
hroederld Oct 9, 2020
8919a07
make test less ambiguous
hroederld Oct 10, 2020
f1808d9
Merge pull request #272 from launchdarkly/hr/ch90672/socketfactory-te…
hroederld Oct 10, 2020
9b20c08
merge from public after release
LaunchDarklyCI Oct 10, 2020
d727737
copy rules to new FlagBuilder instances (#273)
bwoskow-ld Dec 1, 2020
51cb8cf
merge from public after release
LaunchDarklyCI Dec 2, 2020
ace4ad4
Bump guava version (#274)
bwoskow-ld Jan 6, 2021
f86c2c6
merge from public after release
LaunchDarklyCI Jan 15, 2021
88a2e8b
Removed the guides link
bwoskow-ld Feb 3, 2021
9f2ab7b
increment versions when loading file data, so FlagTracker will work (…
eli-darkly Feb 19, 2021
3ba8b90
merge from public after release
LaunchDarklyCI Feb 20, 2021
0d6e3c6
add ability to ignore duplicate keys in file data (#276)
eli-darkly Mar 9, 2021
148dcf1
merge from public after release
LaunchDarklyCI Mar 9, 2021
57e4dd2
add alias events (#278)
apache-hb Apr 5, 2021
89efd68
add validation of javadoc build to CI
eli-darkly Apr 8, 2021
385e79d
update commons-codec to 1.15 (#279)
eli-darkly Apr 8, 2021
aca7716
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Apr 8, 2021
d2b62d1
Merge pull request #280 from launchdarkly/eb/ch105283/check-javadoc
eli-darkly Apr 8, 2021
c53e39c
Add support for experiment rollouts
robertjneal Apr 8, 2021
378b7e3
add tests and use seed for allocating user to partition
robertjneal Apr 9, 2021
c84651c
test serialization and add check for isExperiment
robertjneal Apr 9, 2021
d0e30d2
Merge branch 'master' into rneal/ch101658/add-support-for-experiment-…
robertjneal Apr 14, 2021
b4190ad
fix PollingProcessorTest test race condition + other test issues (#282)
eli-darkly Apr 14, 2021
b26f704
Merge branch 'master' into rneal/ch101658/add-support-for-experiment-…
eli-darkly Apr 14, 2021
fbd6d16
use launchdarkly-java-sdk-common 1.1.0-alpha-expalloc.2
eli-darkly Apr 14, 2021
777b3f3
Update src/test/java/com/launchdarkly/sdk/server/EvaluatorTest.java
robertjneal Apr 14, 2021
99fba91
Update src/test/java/com/launchdarkly/sdk/server/EvaluatorTest.java
robertjneal Apr 14, 2021
2809609
Update src/test/java/com/launchdarkly/sdk/server/EvaluatorTest.java
robertjneal Apr 14, 2021
61ab96d
Update src/test/java/com/launchdarkly/sdk/server/EvaluatorTest.java
robertjneal Apr 14, 2021
d2b53a3
changes per code review comments
robertjneal Apr 15, 2021
4b787a9
Merge branch 'rneal/ch101658/add-support-for-experiment-rollouts' of …
robertjneal Apr 15, 2021
47b9ebb
Please enter the commit message for your changes. Lines starting
robertjneal Apr 15, 2021
3903d54
fix null pointer exception
robertjneal Apr 16, 2021
112f052
address code review comments
robertjneal Apr 19, 2021
4765c66
address more comments
robertjneal Apr 19, 2021
12ee439
missed a ! for isUntracked()
robertjneal Apr 19, 2021
9ed9b2c
fix default boolean for json
robertjneal Apr 19, 2021
d651d26
make untracked FALSE by default
robertjneal Apr 19, 2021
176d7ce
refactoring of bucketing logic to remove the need for an extra result…
eli-darkly Apr 20, 2021
de65f7b
add comment to enum
robertjneal Apr 20, 2021
20e2916
Merge branch 'rneal/ch101658/add-support-for-experiment-rollouts' of …
robertjneal Apr 20, 2021
c05a64a
Merge pull request #281 from launchdarkly/rneal/ch101658/add-support-…
robertjneal Apr 20, 2021
d8c06ec
various JSON fixes, update common-sdk (#284)
eli-darkly Apr 22, 2021
cd8461e
merge from public after release
LaunchDarklyCI Apr 22, 2021
0991ed8
Merge branch 'master' of github.com:launchdarkly/java-server-sdk
eli-darkly Apr 23, 2021
95440c7
simlpify the logic and make it match node/.Net sdks
robertjneal Jun 1, 2021
f695931
Merge branch 'master' into exp-alloc
robertjneal Jun 1, 2021
bf3c9c5
Update src/main/java/com/launchdarkly/sdk/server/EventFactory.java
robertjneal Jun 1, 2021
ee1268b
add the same comment as the Node SDK
robertjneal Jun 2, 2021
abb667c
Merge pull request #285 from launchdarkly/rneal/ch107295/simplify-log…
robertjneal Jun 3, 2021
58367e0
Remove outdated/meaningless doc comment. (#286)
gwhelanLD Jun 9, 2021
72c3096
protect against NPEs if flag/segment JSON contains a null value
eli-darkly Jun 10, 2021
44a25fb
Merge pull request #287 from launchdarkly/eb/ch111218/tolerate-nulls
eli-darkly Jun 10, 2021
040909c
merge from public after release
LaunchDarklyCI Jun 11, 2021
c944996
Merge branch 'exp-alloc'
eli-darkly Jun 17, 2021
c5ad21b
use java-sdk-common 1.2.0
eli-darkly Jun 17, 2021
01f642f
fix Jackson-related build issues (again) (#288)
eli-darkly Jun 18, 2021
75322c2
merge from public after release
LaunchDarklyCI Jun 18, 2021
2d6ac72
update to okhttp-eventsource patch for stream retry bug, improve test…
eli-darkly Jun 24, 2021
093a350
merge from public after release
LaunchDarklyCI Jun 25, 2021
4b847a5
add public builder for FeatureFlagsState (#290)
eli-darkly Jun 25, 2021
b66328d
clarify FileData doc comment to say you shouldn't use offline mode (#…
eli-darkly Jun 25, 2021
04b9db7
improve validation of SDK key so we won't throw an exception that con…
eli-darkly Jul 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 104 additions & 35 deletions src/main/java/com/launchdarkly/sdk/server/FeatureFlagsState.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.launchdarkly.sdk.server;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.stream.JsonReader;
Expand All @@ -10,7 +12,6 @@
import com.launchdarkly.sdk.server.interfaces.LDClientInterface;

import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand All @@ -36,19 +37,20 @@
*/
@JsonAdapter(FeatureFlagsState.JsonSerialization.class)
public final class FeatureFlagsState implements JsonSerializable {
private final Map<String, LDValue> flagValues;
private final Map<String, FlagMetadata> flagMetadata;
private final ImmutableMap<String, FlagMetadata> flagMetadata;
private final boolean valid;

static class FlagMetadata {
final LDValue value;
final Integer variation;
final EvaluationReason reason;
final Integer version;
final Boolean trackEvents;
final Long debugEventsUntilDate;

FlagMetadata(Integer variation, EvaluationReason reason, Integer version, boolean trackEvents,
Long debugEventsUntilDate) {
FlagMetadata(LDValue value, Integer variation, EvaluationReason reason, Integer version,
boolean trackEvents, Long debugEventsUntilDate) {
this.value = LDValue.normalize(value);
this.variation = variation;
this.reason = reason;
this.version = version;
Expand All @@ -60,7 +62,8 @@ static class FlagMetadata {
public boolean equals(Object other) {
if (other instanceof FlagMetadata) {
FlagMetadata o = (FlagMetadata)other;
return Objects.equals(variation, o.variation) &&
return value.equals(o.value) &&
Objects.equals(variation, o.variation) &&
Objects.equals(reason, o.reason) &&
Objects.equals(version, o.version) &&
Objects.equals(trackEvents, o.trackEvents) &&
Expand All @@ -75,13 +78,27 @@ public int hashCode() {
}
}

private FeatureFlagsState(Map<String, LDValue> flagValues,
Map<String, FlagMetadata> flagMetadata, boolean valid) {
this.flagValues = Collections.unmodifiableMap(flagValues);
this.flagMetadata = Collections.unmodifiableMap(flagMetadata);
private FeatureFlagsState(ImmutableMap<String, FlagMetadata> flagMetadata, boolean valid) {
this.flagMetadata = flagMetadata;
this.valid = valid;
}

/**
* Returns a {@link Builder} for creating instances.
* <p>
* Application code will not normally use this builder, since the SDK creates its own instances.
* However, it may be useful in testing, to simulate values that might be returned by
* {@link LDClient#allFlagsState(com.launchdarkly.sdk.LDUser, FlagsStateOption...)}.
*
* @param options the same {@link FlagsStateOption}s, if any, that would be passed to
* {@link LDClient#allFlagsState(com.launchdarkly.sdk.LDUser, FlagsStateOption...)}
* @return a builder object
* @since 5.6.0
*/
public static Builder builder(FlagsStateOption... options) {
return new Builder(options);
}

/**
* Returns true if this object contains a valid snapshot of feature flag state, or false if the
* state could not be computed (for instance, because the client was offline or there was no user).
Expand All @@ -98,7 +115,8 @@ public boolean isValid() {
* {@code null} if there was no such flag
*/
public LDValue getFlagValue(String key) {
return flagValues.get(key);
FlagMetadata data = flagMetadata.get(key);
return data == null ? null : data.value;
}

/**
Expand All @@ -115,64 +133,100 @@ public EvaluationReason getFlagReason(String key) {
* Returns a map of flag keys to flag values. If a flag would have evaluated to the default value,
* its value will be null.
* <p>
* The returned map is unmodifiable.
* <p>
* Do not use this method if you are passing data to the front end to "bootstrap" the JavaScript client.
* Instead, serialize the FeatureFlagsState object to JSON using {@code Gson.toJson()} or {@code Gson.toJsonTree()}.
* @return an immutable map of flag keys to JSON values
*/
public Map<String, LDValue> toValuesMap() {
return flagValues;
return Maps.transformValues(flagMetadata, v -> v.value);
}

@Override
public boolean equals(Object other) {
if (other instanceof FeatureFlagsState) {
FeatureFlagsState o = (FeatureFlagsState)other;
return flagValues.equals(o.flagValues) &&
flagMetadata.equals(o.flagMetadata) &&
return flagMetadata.equals(o.flagMetadata) &&
valid == o.valid;
}
return false;
}

@Override
public int hashCode() {
return Objects.hash(flagValues, flagMetadata, valid);
return Objects.hash(flagMetadata, valid);
}

static class Builder {
private Map<String, LDValue> flagValues = new HashMap<>();
private Map<String, FlagMetadata> flagMetadata = new HashMap<>();
/**
* A builder for a {@link FeatureFlagsState} instance.
* <p>
* Application code will not normally use this builder, since the SDK creates its own instances.
* However, it may be useful in testing, to simulate values that might be returned by
* {@link LDClient#allFlagsState(com.launchdarkly.sdk.LDUser, FlagsStateOption...)}.
*
* @since 5.6.0
*/
public static class Builder {
private ImmutableMap.Builder<String, FlagMetadata> flagMetadata = ImmutableMap.builder();
private final boolean saveReasons;
private final boolean detailsOnlyForTrackedFlags;
private boolean valid = true;

Builder(FlagsStateOption... options) {
private Builder(FlagsStateOption... options) {
saveReasons = FlagsStateOption.hasOption(options, FlagsStateOption.WITH_REASONS);
detailsOnlyForTrackedFlags = FlagsStateOption.hasOption(options, FlagsStateOption.DETAILS_ONLY_FOR_TRACKED_FLAGS);
}

Builder valid(boolean valid) {
/**
* Sets the {@link FeatureFlagsState#isValid()} property. This is true by default.
*
* @param valid the new property value
* @return the builder
*/
public Builder valid(boolean valid) {
this.valid = valid;
return this;
}

Builder addFlag(DataModel.FeatureFlag flag, Evaluator.EvalResult eval) {
flagValues.put(flag.getKey(), eval.getValue());
final boolean flagIsTracked = flag.isTrackEvents() ||
(flag.getDebugEventsUntilDate() != null && flag.getDebugEventsUntilDate() > System.currentTimeMillis());
public Builder add(
String flagKey,
LDValue value,
Integer variationIndex,
EvaluationReason reason,
int flagVersion,
boolean trackEvents,
Long debugEventsUntilDate
) {
final boolean flagIsTracked = trackEvents ||
(debugEventsUntilDate != null && debugEventsUntilDate > System.currentTimeMillis());
final boolean wantDetails = !detailsOnlyForTrackedFlags || flagIsTracked;
FlagMetadata data = new FlagMetadata(
value,
variationIndex,
(saveReasons && wantDetails) ? reason : null,
wantDetails ? Integer.valueOf(flagVersion) : null,
trackEvents,
debugEventsUntilDate
);
flagMetadata.put(flagKey, data);
return this;
}

Builder addFlag(DataModel.FeatureFlag flag, Evaluator.EvalResult eval) {
return add(
flag.getKey(),
eval.getValue(),
eval.isDefault() ? null : eval.getVariationIndex(),
(saveReasons && wantDetails) ? eval.getReason() : null,
wantDetails ? flag.getVersion() : null,
eval.getReason(),
flag.getVersion(),
flag.isTrackEvents(),
flag.getDebugEventsUntilDate());
flagMetadata.put(flag.getKey(), data);
return this;
flag.getDebugEventsUntilDate()
);
}

FeatureFlagsState build() {
return new FeatureFlagsState(flagValues, flagMetadata, valid);
return new FeatureFlagsState(flagMetadata.build(), valid);
}
}

Expand All @@ -181,9 +235,9 @@ static class JsonSerialization extends TypeAdapter<FeatureFlagsState> {
public void write(JsonWriter out, FeatureFlagsState state) throws IOException {
out.beginObject();

for (Map.Entry<String, LDValue> entry: state.flagValues.entrySet()) {
for (Map.Entry<String, FlagMetadata> entry: state.flagMetadata.entrySet()) {
out.name(entry.getKey());
gsonInstance().toJson(entry.getValue(), LDValue.class, out);
gsonInstance().toJson(entry.getValue().value, LDValue.class, out);
}

out.name("$flagsState");
Expand Down Expand Up @@ -229,7 +283,7 @@ public void write(JsonWriter out, FeatureFlagsState state) throws IOException {
@Override
public FeatureFlagsState read(JsonReader in) throws IOException {
Map<String, LDValue> flagValues = new HashMap<>();
Map<String, FlagMetadata> flagMetadata = new HashMap<>();
Map<String, FlagMetadata> flagMetadataWithoutValues = new HashMap<>();
boolean valid = true;
in.beginObject();
while (in.hasNext()) {
Expand All @@ -239,7 +293,7 @@ public FeatureFlagsState read(JsonReader in) throws IOException {
while (in.hasNext()) {
String metaName = in.nextName();
FlagMetadata meta = gsonInstance().fromJson(in, FlagMetadata.class);
flagMetadata.put(metaName, meta);
flagMetadataWithoutValues.put(metaName, meta);
}
in.endObject();
} else if (name.equals("$valid")) {
Expand All @@ -250,7 +304,22 @@ public FeatureFlagsState read(JsonReader in) throws IOException {
}
}
in.endObject();
return new FeatureFlagsState(flagValues, flagMetadata, valid);
ImmutableMap.Builder<String, FlagMetadata> allFlagMetadata = ImmutableMap.builder();
for (Map.Entry<String, LDValue> e: flagValues.entrySet()) {
FlagMetadata m0 = flagMetadataWithoutValues.get(e.getKey());
if (m0 != null) {
FlagMetadata m1 = new FlagMetadata(
e.getValue(),
m0.variation,
m0.reason,
m0.version,
m0.trackEvents != null && m0.trackEvents.booleanValue(),
m0.debugEventsUntilDate
);
allFlagMetadata.put(e.getKey(), m1);
}
}
return new FeatureFlagsState(allFlagMetadata.build(), valid);
}
}
}
28 changes: 27 additions & 1 deletion src/main/java/com/launchdarkly/sdk/server/LDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static com.launchdarkly.sdk.EvaluationDetail.NO_VARIATION;
import static com.launchdarkly.sdk.server.DataModel.FEATURES;
import static com.launchdarkly.sdk.server.DataModel.SEGMENTS;
import static com.launchdarkly.sdk.server.Util.isAsciiHeaderValue;

/**
* A client for the LaunchDarkly API. Client instances are thread-safe. Applications should instantiate
Expand Down Expand Up @@ -82,8 +83,15 @@ public final class LDClient implements LDClientInterface {
* values; it will still continue trying to connect in the background. You can detect whether
* initialization has succeeded by calling {@link #isInitialized()}. If you prefer to customize
* this behavior, use {@link LDClient#LDClient(String, LDConfig)} instead.
* <p>
* For rules regarding the throwing of unchecked exceptions for error conditions, see
* {@link LDClient#LDClient(String, LDConfig)}.
*
* @param sdkKey the SDK key for your LaunchDarkly environment
* @throws IllegalArgumentException if a parameter contained a grossly malformed value;
* for security reasons, in case of an illegal SDK key, the exception message does
* not include the key
* @throws NullPointerException if a non-nullable parameter was null
* @see LDClient#LDClient(String, LDConfig)
*/
public LDClient(String sdkKey) {
Expand Down Expand Up @@ -136,14 +144,32 @@ private static final DataModel.Segment getSegment(DataStore store, String key) {
* // do whatever is appropriate if initialization has timed out
* }
* </code></pre>
* <p>
* This constructor can throw unchecked exceptions if it is immediately apparent that
* the SDK cannot work with these parameters. For instance, if the SDK key contains a
* non-printable character that cannot be used in an HTTP header, it will throw an
* {@link IllegalArgumentException} since the SDK key is normally sent to LaunchDarkly
* in an HTTP header and no such value could possibly be valid. Similarly, a null
* value for a non-nullable parameter may throw a {@link NullPointerException}. The
* constructor will not throw an exception for any error condition that could only be
* detected after making a request to LaunchDarkly (such as an SDK key that is simply
* wrong despite being valid ASCII, so it is invalid but not illegal); those are logged
* and treated as an unsuccessful initialization, as described above.
*
* @param sdkKey the SDK key for your LaunchDarkly environment
* @param config a client configuration object
* @throws IllegalArgumentException if a parameter contained a grossly malformed value;
* for security reasons, in case of an illegal SDK key, the exception message does
* not include the key
* @throws NullPointerException if a non-nullable parameter was null
* @see LDClient#LDClient(String, LDConfig)
*/
public LDClient(String sdkKey, LDConfig config) {
checkNotNull(config, "config must not be null");
this.sdkKey = checkNotNull(sdkKey, "sdkKey must not be null");
if (!isAsciiHeaderValue(sdkKey) ) {
throw new IllegalArgumentException("SDK key contained an invalid character");
}
this.offline = config.offline;

this.sharedExecutor = createSharedExecutor(config);
Expand Down Expand Up @@ -268,7 +294,7 @@ private void sendFlagRequestEvent(Event.FeatureRequest event) {

@Override
public FeatureFlagsState allFlagsState(LDUser user, FlagsStateOption... options) {
FeatureFlagsState.Builder builder = new FeatureFlagsState.Builder(options);
FeatureFlagsState.Builder builder = FeatureFlagsState.builder(options);

if (isOffline()) {
Loggers.EVALUATION.debug("allFlagsState() was called when client is in offline mode.");
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/launchdarkly/sdk/server/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ static Headers.Builder getHeadersBuilderFor(HttpConfiguration config) {
return builder;
}

// This is specifically testing whether the string would be considered a valid HTTP header value
// *by the OkHttp client*. The actual HTTP spec does not prohibit characters >= 127; OkHttp's
// check is overly strict, as was pointed out in https://github.com/square/okhttp/issues/2016.
// But all OkHttp 3.x and 4.x versions so far have continued to enforce that check. Control
// characters other than a tab are always illegal.
//
// The value we're mainly concerned with is the SDK key (Authorization header). If an SDK key
// accidentally has (for instance) a newline added to it, we don't want to end up having OkHttp
// throw an exception mentioning the value, which might get logged (https://github.com/square/okhttp/issues/6738).
static boolean isAsciiHeaderValue(String value) {
for (int i = 0; i < value.length(); i++) {
char ch = value.charAt(i);
if ((ch < 0x20 || ch > 0x7e) && ch != '\t') {
return false;
}
}
return true;
}

static void configureHttpClientBuilder(HttpConfiguration config, OkHttpClient.Builder builder) {
builder.connectionPool(new ConnectionPool(5, 5, TimeUnit.SECONDS))
.connectTimeout(config.getConnectTimeout())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.launchdarkly.sdk.server.integrations;

import com.launchdarkly.sdk.server.LDConfig;

/**
* Integration between the LaunchDarkly SDK and file data.
* <p>
Expand Down Expand Up @@ -56,8 +58,10 @@ public enum DuplicateKeysHandling {
* <p>
* This will cause the client <i>not</i> to connect to LaunchDarkly to get feature flags. The
* client may still make network connections to send analytics events, unless you have disabled
* this with {@link com.launchdarkly.sdk.server.Components#noEvents()} or
* {@link com.launchdarkly.sdk.server.LDConfig.Builder#offline(boolean)}.
* this with {@link com.launchdarkly.sdk.server.Components#noEvents()}. IMPORTANT: Do <i>not</i>
* set {@link LDConfig.Builder#offline(boolean)} to {@code true}; doing so would not just put the
* SDK "offline" with regard to LaunchDarkly, but will completely turn off all flag data sources
* to the SDK <i>including the file data source</i>.
* <p>
* Flag data files can be either JSON or YAML. They contain an object with three possible
* properties:
Expand Down
Loading