All notable changes to the LaunchDarkly Java SDK will be documented in this file. This project adheres to Semantic Versioning.
- Under conditions where analytics events are being generated at an extremely high rate (for instance, if an application is evaluating a flag repeatedly in a tight loop on many threads), a thread could be blocked indefinitely within the
Variation
methods while waiting for the internal event processing logic to catch up with the backlog. The logic has been changed to drop events if necessary so threads will not be blocked (similar to how the SDK already drops events if the size of the event buffer is exceeded). If that happens, this warning message will be logged once: "Events are being produced faster than they can be processed; some events will be dropped". Under normal conditions this should never happen; this change is meant to avoid a concurrency bottleneck in applications that are already so busy that thread starvation is likely.
- The
LDConfig.Builder
methoduserKeysFlushInterval
was mistakenly setting the value offlushInterval
instead. (Thanks, kutsal!)
- CI tests now run against Java 8, 9, 10, and 11.
- Changed the artifact name from
com.launchdarkly:launchdarkly-client
tocom.launchdarkly:launchdarkly-java-server-sdk
- Changed repository references to use the new URL
There are no other changes in this release. Substituting launchdarkly-client
version 4.6.3 with launchdarkly-java-server-sdk
version 4.6.4 will not affect functionality.
- The SDK uberjars contained some JSR305 annotation classes such as
javax.annotation.Nullable
. These have been removed. They were not being used in the public API anyway. (#156) - If
track
oridentify
is called without a user, the SDK now logs a warning, and does not send an analytics event to LaunchDarkly (since it would not be processed without a user).
The LaunchDarkly SDK repositories are being renamed for consistency. This repository is now java-server-sdk
rather than java-client
.
The artifact names will also change. In the 4.6.3 release, the generated artifact was named com.launchdarkly.client:launchdarkly-client
; in all future releases, it will be com.launchdarkly.client:launchdarkly-java-server-sdk
.
- If an unrecoverable
java.lang.Error
is thrown within the analytics event dispatching thread, the SDK will now log the error stacktrace to the configured logger and then disable event sending, so that all further events are simply discarded. Previously, the SDK could be left in a state where application threads would continue trying to push events onto a queue that was no longer being consumed, which could block those threads. The SDK will not attempt to restart the event thread after such a failure, because anError
typically indicates a serious problem with the application environment. - Summary event counters now use 64-bit integers instead of 32-bit, so they will not overflow if there is an extremely large volume of events.
- The SDK's CI test suite now includes running the tests in Windows.
- Fixed a potential race condition that could happen when using a DynamoDB or Consul feature store. The Redis feature store was not affected.
- The SDK jars now contain OSGi manifests which should make it possible to use them as bundles. The default jar requires Gson and SLF4J to be provided by other bundles, while the jar with the "all" classifier contains versions of Gson and SLF4J which it both exports and imports (i.e. it self-wires them, so it will use a higher version if you provide one). The "thin" jar is not recommended in an OSGi environment because it requires many dependencies which may not be available as bundles.
- There are now helper classes that make it much simpler to write a custom
FeatureStore
implementation. See thecom.launchdarkly.client.utils
package. The Redis feature store has been revised to use this code, although its functionality is unchanged except for the fix mentioned below. FeatureStore
caching parameters (for Redis or other databases) are now encapsulated in theFeatureStoreCacheConfig
class.
- The exponential backoff behavior when a stream connection fails has changed as follows. Previously, the backoff delay would increase for each attempt if the connection could not be made at all, or if a read timeout happened; but if a connection was made and then an error (other than a timeout) occurred, the delay would be reset to the minimum value. Now, the delay is only reset if a stream connection is made and remains open for at least a minute.
- The Redis feature store would incorrectly report that it had not been initialized, if there happened to be no feature flags in your environment at the time that it was initialized.
- The
RedisFeatureStoreBuilder
methodscacheTime
,refreshStaleValues
, andasyncRefresh
are deprecated in favor of the newcaching
method which sets these all at once.
- Fixed a build error that caused the
com.launchdarkly.client.files
package (the test file data source component added in v4.5.0) to be inaccessible unless you were using the "thin" jar. - Stream connection errors are now logged at
WARN
level, rather thanERROR
.
It is now possible to inject feature flags into the client from local JSON or YAML files, replacing the normal LaunchDarkly connection. This would typically be for testing purposes. See com.launchdarkly.client.files.FileComponents
.
- The SDK's Maven releases had a
pom.xml
that mistakenly referenced dependencies that are actually bundled (with shading) inside of our jar, resulting in those dependencies being redundantly downloaded and included (without shading) in the runtime classpath, which could cause conflicts. This has been fixed. (#122)
- The
allFlagsState()
method now accepts a new option,FlagsStateOption.DETAILS_ONLY_FOR_TRACKED_FLAGS
, which reduces the size of the JSON representation of the flag state by omitting some metadata. Specifically, it omits any data that is normally used for generating detailed evaluation events if a flag does not have event tracking or debugging turned on.
- JSON data from
allFlagsState()
is now slightly smaller even if you do not use the new option described above, because it completely omits the flag property for event tracking unless that property istrue
.
- Event delivery now works correctly when the events are being forwarded through a LaunchDarkly Relay Proxy.
- When evaluating a prerequisite feature flag, the analytics event for the evaluation did not include the result value if the prerequisite flag was off.
- The default Gson serialization for
LDUser
now includes all user properties. Previously, it omittedprivateAttributeNames
.
- The new
LDClient
methodallFlagsState()
should be used instead ofallFlags()
if you are passing flag data to the front end for use with the JavaScript SDK. It preserves some flag metadata that the front end requires in order to send analytics events correctly. Versions 2.5.0 and above of the JavaScript SDK are able to use this metadata, but the output ofallFlagsState()
will still work with older versions. - The
allFlagsState()
method also allows you to select only client-side-enabled flags to pass to the front end, by using the optionFlagsStateOption.CLIENT_SIDE_ONLY
. (#112) - The new
LDClient
methodsboolVariationDetail
,intVariationDetail
,doubleVariationDetail
,stringVariationDetail
, andjsonVariationDetail
allow you to evaluate a feature flag (using the same parameters as you would forboolVariation
, etc.) and receive more information about how the value was calculated. This information is returned in anEvaluationDetail
object, which contains both the result value and anEvaluationReason
which will tell you, for instance, if the user was individually targeted for the flag or was matched by one of the flag's rules, or if the flag returned the default value due to an error.
- Fixed a bug in
LDUser.Builder
that would throw an exception if you initialized the builder by copying an existing user, and then tried to add a custom attribute.
LDClient.allFlags()
- When logging errors related to the evaluation of a specific flag, the log message now always includes the flag key.
- Exception stacktraces are now logged only at DEBUG level. Previously, some were being logged at ERROR level.
- Should not permanently give up on posting events if the server returns a 400 error.
- Fixed a bug in the Redis store that caused an unnecessary extra Redis query (and a debug-level log message about updating a flag with the same version) after every update of a flag.
- New overloads of
LDUser.Builder.custom
andLDUser.Builder.privateCustom
allow you to set a custom attribute value to any JSON element.
- The client now treats most HTTP 4xx errors as unrecoverable: that is, after receiving such an error, it will not make any more HTTP requests for the lifetime of the client instance, in effect taking the client offline. This is because such errors indicate either a configuration problem (invalid SDK key) or a bug, which is not likely to resolve without a restart or an upgrade. This does not apply if the error is 400, 408, 429, or any 5xx error.
- During initialization, if the client receives any of the unrecoverable errors described above, the client constructor will return immediately; previously it would continue waiting until a timeout. The
initialized()
method will return false in this case.
- The new user builder methods
customValues
andprivateCustomValues
allow you to add a custom user attribute with multiple JSON values of mixed types. (#126) - The new constant
VersionedDataKind.ALL
is a list of all existingVersionedDataKind
instances. This is mainly useful if you are writing a customFeatureStore
implementation.
- To reduce the network bandwidth used for analytics events, feature request events are now sent as counters rather than individual events, and user details are now sent only at intervals rather than in each event. These behaviors can be modified through the LaunchDarkly UI and with the new configuration option
inlineUsersInEvents
. For more details, see Analytics Data Stream Reference. - When sending analytics events, if there is a connection error or an HTTP 5xx response, the client will try to send the events again one more time after a one-second delay.
- The
LdClient
class is nowfinal
.
- New methods on
LDConfig.Builder
(updateProcessorFactory
,featureStoreFactory
,eventProcessorFactory
) allow you to specify different implementations of each of the main client subcomponents (receiving feature state, storing feature state, and sending analytics events) for testing or for any other purpose. TheComponents
class provides factories for all built-in implementations of these.
- The
featureStore
configuration method is deprecated, replaced by the new factory-based mechanism described above.
- In the Redis feature store, fixed a synchronization problem that could cause a feature flag update to be missed if several of them happened in rapid succession.
- Fixed a bug that would cause a
NullPointerException
when trying to evaluate a flag rule that contained an unknown operator type. This could happen if you started using some recently added feature flag functionality in the LaunchDarkly application but had not yet upgraded the SDK to a version that supports that feature. In this case, it should now simply treat that rule as a non-match.
- The log message "Attempted to update ... with a version that is the same or older" has been downgraded from
WARN
level toDEBUG
. It can happen frequently in normal operation when the client is in streaming mode, and is not a cause for concern.
- Improved performance when evaluating flags with custom attributes, by avoiding an unnecessary caught exception (thanks, rbalamohan).
- Support for a new LaunchDarkly feature: reusable user segments.
- The
FeatureStore
interface has been changed to support user segment data as well as feature flags. Existing code that usesInMemoryFeatureStore
orRedisFeatureStore
should work as before, but custom feature store implementations will need to be updated. - Removed deprecated methods.
This release was broken and should not be used.
- Improved performance when evaluating flags with custom attributes, by avoiding an unnecessary caught exception (thanks, rbalamohan).
- Adds support for a future LaunchDarkly feature, coming soon: semantic version user attributes.
- It is now possible to compute rollouts based on an integer attribute of a user, not just a string attribute.
- All threads created by the client are now daemon threads.
- Fixed a bug that could result in a previously deleted feature flag appearing to be available again.
- Reduced the logging level for use of an unknown feature flag from
WARN
toINFO
.
- Support for specifying private user attributes in order to prevent user attributes from being sent in analytics events back to LaunchDarkly. See the
allAttributesPrivate
andprivateAttributeNames
methods onLDConfig.Builder
as well as theprivateX
methods onLDUser.Builder
.
- Added an option to disable sending analytics events
- No longer attempt to reconnect if a 401 response is received (this would indicate an invalid SDK key, so retrying won't help)
- Simplified logic to detect dropped stream connections
- Increased default polling interval to 30s
- Use flag data in redis before stream connection is established, if possible (See #107)
- Avoid creating HTTP cache when streaming mode is enabled (as it won't be useful). This makes it possible to use the SDK in Google App Engine and other environments with no mutable disk access.
- Removed GSON dependency from default jar (fixes #103)
- Only log a warning on the first event that overflows the event buffer [#102]
- Updated okhttp-eventsource dependency to 1.5.0 to pick up better connection timeout handling.
- LDUser
Builder
constructor which accepts a previously built user as an initialization parameter.
- #96
LDUser
now hasequals()
andhashCode()
methods
- #93
LDClient
now releases resources more quickly when shutting down
- Improved Gson compatibility (added no-args constructors for classes we deserialize)
- Automated release process
- Improved Gson compatibility (added no-args constructors for classes we deserialize)
- Automated release process
- Fixed issue where stream connection failed to fully establish
- In Java 7, connections to LaunchDarkly are now possible using TLSv1.1 and/or TLSv1.2
- The order of SSE stream events is now preserved. (launchdarkly/okhttp-eventsource#19)
- #92 Regex
matches
targeting rules now include the user if a match is found anywhere in the attribute. Before fixing this bug, the entire attribute needed to match the pattern.
- Authentication for proxied http requests is now supported (Basic Auth only)
- Improved Redis connection pool management.
- LdClientInterface (and its implementation) have a new method:
boolean isFlagKnown(String featureKey)
which checks for a feature flag's existence. Thanks @yuv422!
- EventProcessor now respects the connect and socket timeouts configured with LDConfig.
- Updated okhttp-eventsource dependency to bring in newer okhttp dependency
- Added more verbose debug level logging when sending events
- StreamProcessor uses the proxy configuration specified by LDConfig.
- Better handling of null default values.
- allFlags() method on client no longer returns null when client is in offline mode.
- RedisFeatureStore: Update Jedis dependency. Improved thread/memory management.
- The StreamProcessor now listens for heartbeats from the streaming API, and will automatically reconnect if heartbeats are not received.
- Updated GSON dependency version to 2.7
- StreamingProcessor now supports increasing retry delays with jitter. Addresses [https://github.com/launchdarkly/java-server-sdk/issues/74[(https://github.com/launchdarkly/java-server-sdk/issues/74)
- Now publishing artifact with 'all' classifier that includes SLF4J for ColdFusion or other systems that need it.
- Removed slf4j from default artifact: #71
- Support for multivariate feature flags. New methods
boolVariation
,jsonVariation
andintVariation
anddoubleVariation
for multivariates. - Added
LDClientInterface
, an interface suitable for mockingLDClient
.
- The
Feature
data model has been replaced withFeatureFlag
.FeatureFlag
is not generic. - The
allFlags
method now returns aMap<String, JsonElement>
to support multivariate flags.
- The
toggle
call has been deprecated in favor ofboolVariation
.
- The
getFlag
call has been removed. - The
debugStreaming
configuration option has been removed.