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

Commit 5f92f7f

Browse files
authored
prepare 4.3.0 release (#134)
1 parent a77e817 commit 5f92f7f

32 files changed

+1998
-309
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

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

6+
## [4.3.0] - 2018-08-27
7+
### Added:
8+
- 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.
9+
- 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))
10+
- 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.
11+
12+
### Fixed:
13+
- 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.
14+
15+
### Deprecated:
16+
- `LDClient.allFlags()`
17+
618
## [4.2.2] - 2018-08-17
719
### Fixed:
820
- When logging errors related to the evaluation of a specific flag, the log message now always includes the flag key.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Quick setup
1818
<dependency>
1919
<groupId>com.launchdarkly</groupId>
2020
<artifactId>launchdarkly-client</artifactId>
21-
<version>4.2.1</version>
21+
<version>4.3.0</version>
2222
</dependency>
2323

2424
1. Import the LaunchDarkly package:

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=4.2.2
1+
version=4.3.0
22
ossrhUsername=
33
ossrhPassword=

src/main/java/com/launchdarkly/client/Components.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public abstract class Components {
1818

1919
/**
2020
* Returns a factory for the default in-memory implementation of {@link FeatureStore}.
21+
* @return a factory object
2122
*/
2223
public static FeatureStoreFactory inMemoryFeatureStore() {
2324
return inMemoryFeatureStoreFactory;
@@ -26,6 +27,7 @@ public static FeatureStoreFactory inMemoryFeatureStore() {
2627
/**
2728
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
2829
* using {@link RedisFeatureStoreBuilder#DEFAULT_URI}.
30+
* @return a factory/builder object
2931
*/
3032
public static RedisFeatureStoreBuilder redisFeatureStore() {
3133
return new RedisFeatureStoreBuilder();
@@ -34,6 +36,8 @@ public static RedisFeatureStoreBuilder redisFeatureStore() {
3436
/**
3537
* Returns a factory with builder methods for creating a Redis-backed implementation of {@link FeatureStore},
3638
* specifying the Redis URI.
39+
* @param redisUri the URI of the Redis host
40+
* @return a factory/builder object
3741
*/
3842
public static RedisFeatureStoreBuilder redisFeatureStore(URI redisUri) {
3943
return new RedisFeatureStoreBuilder(redisUri);
@@ -43,6 +47,7 @@ public static RedisFeatureStoreBuilder redisFeatureStore(URI redisUri) {
4347
* Returns a factory for the default implementation of {@link EventProcessor}, which
4448
* forwards all analytics events to LaunchDarkly (unless the client is offline or you have
4549
* set {@link LDConfig.Builder#sendEvents(boolean)} to {@code false}).
50+
* @return a factory object
4651
*/
4752
public static EventProcessorFactory defaultEventProcessor() {
4853
return defaultEventProcessorFactory;
@@ -51,6 +56,7 @@ public static EventProcessorFactory defaultEventProcessor() {
5156
/**
5257
* Returns a factory for a null implementation of {@link EventProcessor}, which will discard
5358
* all analytics events and not send them to LaunchDarkly, regardless of any other configuration.
59+
* @return a factory object
5460
*/
5561
public static EventProcessorFactory nullEventProcessor() {
5662
return nullEventProcessorFactory;
@@ -60,6 +66,7 @@ public static EventProcessorFactory nullEventProcessor() {
6066
* Returns a factory for the default implementation of {@link UpdateProcessor}, which receives
6167
* feature flag data from LaunchDarkly using either streaming or polling as configured (or does
6268
* nothing if the client is offline, or in LDD mode).
69+
* @return a factory object
6370
*/
6471
public static UpdateProcessorFactory defaultUpdateProcessor() {
6572
return defaultUpdateProcessorFactory;
@@ -68,6 +75,7 @@ public static UpdateProcessorFactory defaultUpdateProcessor() {
6875
/**
6976
* Returns a factory for a null implementation of {@link UpdateProcessor}, which does not
7077
* connect to LaunchDarkly, regardless of any other configuration.
78+
* @return a factory object
7179
*/
7280
public static UpdateProcessorFactory nullUpdateProcessor() {
7381
return nullUpdateProcessorFactory;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.launchdarkly.client;
2+
3+
import com.google.common.base.Objects;
4+
5+
/**
6+
* An object returned by the "variation detail" methods such as {@link LDClientInterface#boolVariationDetail(String, LDUser, boolean)},
7+
* combining the result of a flag evaluation with an explanation of how it was calculated.
8+
* @since 4.3.0
9+
*/
10+
public class EvaluationDetail<T> {
11+
12+
private final EvaluationReason reason;
13+
private final Integer variationIndex;
14+
private final T value;
15+
16+
public EvaluationDetail(EvaluationReason reason, Integer variationIndex, T value) {
17+
this.reason = reason;
18+
this.variationIndex = variationIndex;
19+
this.value = value;
20+
}
21+
22+
static <T> EvaluationDetail<T> error(EvaluationReason.ErrorKind errorKind, T defaultValue) {
23+
return new EvaluationDetail<>(EvaluationReason.error(errorKind), null, defaultValue);
24+
}
25+
26+
/**
27+
* An object describing the main factor that influenced the flag evaluation value.
28+
* @return an {@link EvaluationReason}
29+
*/
30+
public EvaluationReason getReason() {
31+
return reason;
32+
}
33+
34+
/**
35+
* The index of the returned value within the flag's list of variations, e.g. 0 for the first variation -
36+
* or {@code null} if the default value was returned.
37+
* @return the variation index or null
38+
*/
39+
public Integer getVariationIndex() {
40+
return variationIndex;
41+
}
42+
43+
/**
44+
* The result of the flag evaluation. This will be either one of the flag's variations or the default
45+
* value that was passed to the {@code variation} method.
46+
* @return the flag value
47+
*/
48+
public T getValue() {
49+
return value;
50+
}
51+
52+
/**
53+
* Returns true if the flag evaluation returned the default value, rather than one of the flag's
54+
* variations.
55+
* @return true if this is the default value
56+
*/
57+
public boolean isDefaultValue() {
58+
return variationIndex == null;
59+
}
60+
61+
@Override
62+
public boolean equals(Object other) {
63+
if (other instanceof EvaluationDetail) {
64+
@SuppressWarnings("unchecked")
65+
EvaluationDetail<T> o = (EvaluationDetail<T>)other;
66+
return Objects.equal(reason, o.reason) && Objects.equal(variationIndex, o.variationIndex) && Objects.equal(value, o.value);
67+
}
68+
return false;
69+
}
70+
71+
@Override
72+
public int hashCode() {
73+
return Objects.hashCode(reason, variationIndex, value);
74+
}
75+
76+
@Override
77+
public String toString() {
78+
return "{" + reason + "," + variationIndex + "," + value + "}";
79+
}
80+
}

src/main/java/com/launchdarkly/client/EvaluationException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* An error indicating an abnormal result from evaluating a feature
55
*/
6+
@SuppressWarnings("serial")
67
class EvaluationException extends Exception {
78
public EvaluationException(String message) {
89
super(message);

0 commit comments

Comments
 (0)