Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3d95d43
don't give up permanently after a 400 error
eli-darkly Jun 28, 2018
8e2af3a
Merge pull request #77 from launchdarkly/eb/ch19705/400-error
eli-darkly Jun 28, 2018
398202a
implement evaluation with explanation
eli-darkly Jun 29, 2018
8abe79c
use case-class-like type instead of enum + optional fields
eli-darkly Jun 29, 2018
1874e20
fix tests
eli-darkly Jun 29, 2018
e694ab4
misc refactoring & tests
eli-darkly Jun 30, 2018
d692bb3
don't need array index
eli-darkly Jun 30, 2018
9eb8b34
stop using deprecated TestFeatureStore in tests
eli-darkly Jun 30, 2018
afdb396
add brief Java compatibility note to readme
eli-darkly Jul 3, 2018
7520d9e
Merge pull request #79 from launchdarkly/eb/ch19355/readme-java-version
eli-darkly Jul 3, 2018
84efc77
Merge branch 'master' into eb/ch19787/explanation
eli-darkly Jul 3, 2018
d28a57f
Merge branch 'eb/ch19787/explanation' into eb/test-cleanup
eli-darkly Jul 3, 2018
827bb36
Merge pull request #78 from launchdarkly/eb/ch19787/explanation
eli-darkly Jul 9, 2018
935c514
Merge pull request #80 from launchdarkly/eb/test-cleanup
eli-darkly Jul 9, 2018
b9e0634
avoid unnecessary retry after Redis update
eli-darkly Jul 14, 2018
cca7d78
Merge pull request #81 from launchdarkly/eb/ch20410/extra-update
eli-darkly Jul 14, 2018
e4d155c
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Jul 17, 2018
992408f
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Jul 19, 2018
742514e
fix javadoc errors
eli-darkly Jul 20, 2018
b388b63
include explanations, if requested, in full feature request events
eli-darkly Jul 20, 2018
64fe12e
add unit test for reason property in full feature event
eli-darkly Jul 20, 2018
ebfb18a
add javadoc note about reasons in events
eli-darkly Jul 20, 2018
fd1b8d9
Merge pull request #82 from launchdarkly/eb/ch19787/explanations-in-e…
eli-darkly Jul 20, 2018
4810c14
add unit test to verify that the reason object can return a non-zero …
eli-darkly Aug 13, 2018
52951a8
always include ruleIndex in toString()
eli-darkly Aug 14, 2018
fa5df96
make sure kind property gets serialized to JSON
eli-darkly Aug 14, 2018
849f085
version 4.3.0-SNAPSHOT
eli-darkly Aug 14, 2018
2bae5ab
better error logging practices
eli-darkly Aug 16, 2018
361849c
add new version of allFlags() that captures more metadata
eli-darkly Aug 16, 2018
e3cfe15
Merge pull request #84 from launchdarkly/eb/ch22265/error-logging
eli-darkly Aug 16, 2018
1889fb5
clarify comment
eli-darkly Aug 16, 2018
1bcc8a3
Merge branch 'master' into eb/ch21386/all-flags-state-without-reasons
eli-darkly Aug 16, 2018
a4a5695
remove FOSSA upload step from CI
eli-darkly Aug 16, 2018
cc42ed6
Merge pull request #86 from launchdarkly/eb/disable-fossa
eli-darkly Aug 16, 2018
e4ae9cb
add evaluation reasons to allFlagsState()
eli-darkly Aug 16, 2018
de8b9e7
Merge branch 'master' into explanation
eli-darkly Aug 16, 2018
80f7197
Merge branch 'explanation' into eb/ch21386/all-flags-state-with-reasons
eli-darkly Aug 16, 2018
7e91572
rm duplicated test
eli-darkly Aug 16, 2018
a0dcfa7
add error explanation for malformed flags
eli-darkly Aug 16, 2018
712bed4
add tests for more error conditions
eli-darkly Aug 16, 2018
564db86
change options to be more enum-like
eli-darkly Aug 17, 2018
e29c2e0
version 4.2.2 (#88)
eli-darkly Aug 17, 2018
91f9cb2
add option to select only client-side flags in allFlagsState()
eli-darkly Aug 17, 2018
b0f034e
Merge branch 'master' of github.com:launchdarkly/java-client
eli-darkly Aug 17, 2018
a060bcc
fix comment
eli-darkly Aug 17, 2018
8939c8b
serialize FeatureFlagsState to a JsonElement, not a string
eli-darkly Aug 20, 2018
78611fb
rm unused import
eli-darkly Aug 20, 2018
8200e44
edit comment
eli-darkly Aug 20, 2018
bb20933
use custom Gson serializer
eli-darkly Aug 21, 2018
b82f58b
Merge branch 'eb/ch21386/all-flags-state-without-reasons' into eb/ch1…
eli-darkly Aug 21, 2018
20b2914
Merge pull request #85 from launchdarkly/eb/ch21386/all-flags-state-w…
eli-darkly Aug 22, 2018
190cdb9
add tests for JSON serialization of evaluation reasons
eli-darkly Aug 22, 2018
e90f90b
Merge pull request #87 from launchdarkly/eb/malformed-flag-error
eli-darkly Aug 22, 2018
bc5033a
Merge pull request #89 from launchdarkly/eb/ch12124/filter-client-sid…
eli-darkly Aug 22, 2018
b8b6a5b
Merge branch 'all-flags-state' into explanation
eli-darkly Aug 22, 2018
e35d149
Merge branch 'explanation' into eb/ch21386/all-flags-state-with-reasons
eli-darkly Aug 22, 2018
38f01cc
Merge branch 'explanation' into eb/reason-json-tests
eli-darkly Aug 22, 2018
8f90c71
misc cleanup
eli-darkly Aug 23, 2018
ccaddda
don't keep evaluating prerequisites if one fails
eli-darkly Aug 23, 2018
1d20039
Merge branch 'eb/single-prereq-failure' into eb/reason-json-tests
eli-darkly Aug 23, 2018
9a00c07
avoid some inappropriate uses of Guava's ImmutableMap
eli-darkly Aug 23, 2018
d026e18
make map & set in the User immutable
eli-darkly Aug 23, 2018
18ed2d6
fix default value logic
eli-darkly Aug 24, 2018
ab503e8
Merge pull request #94 from launchdarkly/eb/default-values
eli-darkly Aug 25, 2018
1de786b
Merge pull request #93 from launchdarkly/eb/immutable-maps
eli-darkly Aug 25, 2018
e9a31d0
Merge branch 'all-flags-state' into eb/ch21386/all-flags-state-with-r…
eli-darkly Aug 25, 2018
7de5305
Merge pull request #92 from launchdarkly/eb/single-prereq-failure
eli-darkly Aug 25, 2018
001f2e3
Merge pull request #91 from launchdarkly/eb/reason-json-tests
eli-darkly Aug 25, 2018
648a2e6
Merge pull request #90 from launchdarkly/eb/ch21386/all-flags-state-w…
eli-darkly Aug 25, 2018
23613b8
prepare 4.3.0 release
eli-darkly Aug 25, 2018
ac91d56
add issue link
eli-darkly Aug 25, 2018
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@

All notable changes to the LaunchDarkly Java SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [4.3.0] - 2018-08-27
### Added:
- The new `LDClient` method `allFlagsState()` should be used instead of `allFlags()` 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 of `allFlagsState()` 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 option `FlagsStateOption.CLIENT_SIDE_ONLY`. ([#112](https://github.com/launchdarkly/java-client/issues/112))
- The new `LDClient` methods `boolVariationDetail`, `intVariationDetail`, `doubleVariationDetail`, `stringVariationDetail`, and `jsonVariationDetail` allow you to evaluate a feature flag (using the same parameters as you would for `boolVariation`, etc.) and receive more information about how the value was calculated. This information is returned in an `EvaluationDetail` object, which contains both the result value and an `EvaluationReason` 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:
- 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.

### Deprecated:
- `LDClient.allFlags()`

## [4.2.2] - 2018-08-17
### Fixed:
- When logging errors related to the evaluation of a specific flag, the log message now always includes the flag key.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Quick setup
<dependency>
<groupId>com.launchdarkly</groupId>
<artifactId>launchdarkly-client</artifactId>
<version>4.2.1</version>
<version>4.3.0</version>
</dependency>

1. Import the LaunchDarkly package:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=4.2.2
version=4.3.0
ossrhUsername=
ossrhPassword=
8 changes: 8 additions & 0 deletions src/main/java/com/launchdarkly/client/Components.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public abstract class Components {

/**
* Returns a factory for the default in-memory implementation of {@link FeatureStore}.
* @return a factory object
*/
public static FeatureStoreFactory inMemoryFeatureStore() {
return inMemoryFeatureStoreFactory;
Expand All @@ -26,6 +27,7 @@ public static FeatureStoreFactory inMemoryFeatureStore() {
/**
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
* using {@link RedisFeatureStoreBuilder#DEFAULT_URI}.
* @return a factory/builder object
*/
public static RedisFeatureStoreBuilder redisFeatureStore() {
return new RedisFeatureStoreBuilder();
Expand All @@ -34,6 +36,8 @@ public static RedisFeatureStoreBuilder redisFeatureStore() {
/**
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
* specifying the Redis URI.
* @param redisUri the URI of the Redis host
* @return a factory/builder object
*/
public static RedisFeatureStoreBuilder redisFeatureStore(URI redisUri) {
return new RedisFeatureStoreBuilder(redisUri);
Expand All @@ -43,6 +47,7 @@ public static RedisFeatureStoreBuilder redisFeatureStore(URI redisUri) {
* Returns a factory for the default implementation of {@link EventProcessor}, which
* forwards all analytics events to LaunchDarkly (unless the client is offline or you have
* set {@link LDConfig.Builder#sendEvents(boolean)} to {@code false}).
* @return a factory object
*/
public static EventProcessorFactory defaultEventProcessor() {
return defaultEventProcessorFactory;
Expand All @@ -51,6 +56,7 @@ public static EventProcessorFactory defaultEventProcessor() {
/**
* Returns a factory for a null implementation of {@link EventProcessor}, which will discard
* all analytics events and not send them to LaunchDarkly, regardless of any other configuration.
* @return a factory object
*/
public static EventProcessorFactory nullEventProcessor() {
return nullEventProcessorFactory;
Expand All @@ -60,6 +66,7 @@ public static EventProcessorFactory nullEventProcessor() {
* Returns a factory for the default implementation of {@link UpdateProcessor}, which receives
* feature flag data from LaunchDarkly using either streaming or polling as configured (or does
* nothing if the client is offline, or in LDD mode).
* @return a factory object
*/
public static UpdateProcessorFactory defaultUpdateProcessor() {
return defaultUpdateProcessorFactory;
Expand All @@ -68,6 +75,7 @@ public static UpdateProcessorFactory defaultUpdateProcessor() {
/**
* Returns a factory for a null implementation of {@link UpdateProcessor}, which does not
* connect to LaunchDarkly, regardless of any other configuration.
* @return a factory object
*/
public static UpdateProcessorFactory nullUpdateProcessor() {
return nullUpdateProcessorFactory;
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/com/launchdarkly/client/EvaluationDetail.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.launchdarkly.client;

import com.google.common.base.Objects;

/**
* An object returned by the "variation detail" methods such as {@link LDClientInterface#boolVariationDetail(String, LDUser, boolean)},
* combining the result of a flag evaluation with an explanation of how it was calculated.
* @since 4.3.0
*/
public class EvaluationDetail<T> {

private final EvaluationReason reason;
private final Integer variationIndex;
private final T value;

public EvaluationDetail(EvaluationReason reason, Integer variationIndex, T value) {
this.reason = reason;
this.variationIndex = variationIndex;
this.value = value;
}

static <T> EvaluationDetail<T> error(EvaluationReason.ErrorKind errorKind, T defaultValue) {
return new EvaluationDetail<>(EvaluationReason.error(errorKind), null, defaultValue);
}

/**
* An object describing the main factor that influenced the flag evaluation value.
* @return an {@link EvaluationReason}
*/
public EvaluationReason getReason() {
return reason;
}

/**
* The index of the returned value within the flag's list of variations, e.g. 0 for the first variation -
* or {@code null} if the default value was returned.
* @return the variation index or null
*/
public Integer getVariationIndex() {
return variationIndex;
}

/**
* The result of the flag evaluation. This will be either one of the flag's variations or the default
* value that was passed to the {@code variation} method.
* @return the flag value
*/
public T getValue() {
return value;
}

/**
* Returns true if the flag evaluation returned the default value, rather than one of the flag's
* variations.
* @return true if this is the default value
*/
public boolean isDefaultValue() {
return variationIndex == null;
}

@Override
public boolean equals(Object other) {
if (other instanceof EvaluationDetail) {
@SuppressWarnings("unchecked")
EvaluationDetail<T> o = (EvaluationDetail<T>)other;
return Objects.equal(reason, o.reason) && Objects.equal(variationIndex, o.variationIndex) && Objects.equal(value, o.value);
}
return false;
}

@Override
public int hashCode() {
return Objects.hashCode(reason, variationIndex, value);
}

@Override
public String toString() {
return "{" + reason + "," + variationIndex + "," + value + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* An error indicating an abnormal result from evaluating a feature
*/
@SuppressWarnings("serial")
class EvaluationException extends Exception {
public EvaluationException(String message) {
super(message);
Expand Down
Loading