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

Commit c697b09

Browse files
prepare 4.11.1 release (#185)
1 parent aafc29c commit c697b09

File tree

6 files changed

+38
-7
lines changed

6 files changed

+38
-7
lines changed

CHANGELOG.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ All notable changes to the LaunchDarkly Java SDK will be documented in this file
66
### Added:
77
- When an `EvaluationReason` indicates that flag evaluation failed due to an unexpected exception (`getKind()` is `ERROR`, and `EvaluationReason.Error.getErrorKind()` is `EXCEPTION`), you can now examine the underlying exception via `EvaluationReason.Error.getException()`. ([#180](https://github.com/launchdarkly/java-server-sdk/issues/180))
88

9-
### Fixed:
10-
- The SDK now specifies a uniquely identifiable request header when sending events to LaunchDarkly to ensure that events are only processed once, even if the SDK sends them two times due to a failed initial attempt.
11-
129
## [4.10.1] - 2020-01-06
1310
### Fixed:
1411
- The `pom.xml` dependencies were incorrectly specifying `runtime` scope rather than `compile`, causing problems for applications that did not have their own dependencies on Gson and SLF4J. ([#151](https://github.com/launchdarkly/java-client/issues/151))

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package com.launchdarkly.client;
22

3+
import com.google.gson.Gson;
4+
import com.google.gson.TypeAdapter;
5+
import com.google.gson.TypeAdapterFactory;
6+
import com.google.gson.annotations.JsonAdapter;
7+
import com.google.gson.reflect.TypeToken;
8+
import com.google.gson.stream.JsonReader;
9+
import com.google.gson.stream.JsonWriter;
10+
11+
import java.io.IOException;
312
import java.util.Objects;
413

514
import static com.google.common.base.Preconditions.checkNotNull;
@@ -317,7 +326,10 @@ private Fallthrough()
317326
*/
318327
public static class Error extends EvaluationReason {
319328
private final ErrorKind errorKind;
320-
private final Exception exception;
329+
private transient final Exception exception;
330+
// The exception field is transient because we don't want it to be included in the JSON representation that
331+
// is used in analytics events; the LD event service wouldn't know what to do with it (and it would include
332+
// a potentially large amount of stacktrace data).
321333

322334
private Error(ErrorKind errorKind, Exception exception) {
323335
super(Kind.ERROR);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public StaleValuesPolicy getStaleValuesPolicy() {
161161
* Specifies the cache TTL. Items will be evicted or refreshed (depending on {@link #staleValuesPolicy(StaleValuesPolicy)})
162162
* after this amount of time from the time when they were originally cached. If the time is less
163163
* than or equal to zero, caching is disabled.
164+
* after this amount of time from the time when they were originally cached.
165+
* <p>
166+
* If the value is zero, caching is disabled.
164167
*
165168
* @param cacheTime the cache TTL in whatever units you wish
166169
* @param timeUnit the time unit

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public Object getValueAsType(LDValue value) {
2727
case date:
2828
return Util.jsonPrimitiveToDateTime(value);
2929
case semVer:
30+
if (!value.isString()) {
31+
return null;
32+
}
3033
try {
3134
return SemanticVersion.parse(value.stringValue(), true);
3235
} catch (SemanticVersion.InvalidVersionException e) {

src/test/java/com/launchdarkly/client/EvaluationReasonTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,20 @@ public void testPrerequisiteFailedSerialization() {
5454

5555
@Test
5656
public void testErrorSerialization() {
57-
EvaluationReason reason = EvaluationReason.error(EvaluationReason.ErrorKind.EXCEPTION);
57+
EvaluationReason reason = EvaluationReason.error(EvaluationReason.ErrorKind.FLAG_NOT_FOUND);
58+
String json = "{\"kind\":\"ERROR\",\"errorKind\":\"FLAG_NOT_FOUND\"}";
59+
assertJsonEqual(json, gson.toJson(reason));
60+
assertEquals("ERROR(FLAG_NOT_FOUND)", reason.toString());
61+
}
62+
63+
@Test
64+
public void testErrorSerializationWithException() {
65+
// We do *not* want the JSON representation to include the exception, because that is used in events, and
66+
// the LD event service won't know what to do with that field (which will also contain a big stacktrace).
67+
EvaluationReason reason = EvaluationReason.exception(new Exception("something happened"));
5868
String json = "{\"kind\":\"ERROR\",\"errorKind\":\"EXCEPTION\"}";
5969
assertJsonEqual(json, gson.toJson(reason));
60-
assertEquals("ERROR(EXCEPTION)", reason.toString());
70+
assertEquals("ERROR(EXCEPTION,java.lang.Exception: something happened)", reason.toString());
6171
}
6272

6373
@Test

src/test/java/com/launchdarkly/client/OperatorParameterizedTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ public static Iterable<Object[]> data() {
115115
{ Operator.semVerGreaterThan, LDValue.of("2.0"), LDValue.of("2.0.1"), false },
116116
{ Operator.semVerGreaterThan, LDValue.of("2.0.0-rc.1"), LDValue.of("2.0.0-rc.0"), true },
117117
{ Operator.semVerLessThan, LDValue.of("2.0.1"), invalidVer, false },
118-
{ Operator.semVerGreaterThan, LDValue.of("2.0.1"), invalidVer, false }
118+
{ Operator.semVerGreaterThan, LDValue.of("2.0.1"), invalidVer, false },
119+
{ Operator.semVerEqual, LDValue.ofNull(), LDValue.of("2.0.0"), false },
120+
{ Operator.semVerEqual, LDValue.of(1), LDValue.of("2.0.0"), false },
121+
{ Operator.semVerEqual, LDValue.of(true), LDValue.of("2.0.0"), false },
122+
{ Operator.semVerEqual, LDValue.of("2.0.0"), LDValue.ofNull(), false },
123+
{ Operator.semVerEqual, LDValue.of("2.0.0"), LDValue.of(1), false },
124+
{ Operator.semVerEqual, LDValue.of("2.0.0"), LDValue.of(true), false }
119125
});
120126
}
121127

0 commit comments

Comments
 (0)