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

prepare 4.2.2 release #133

Merged
merged 13 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,3 @@ jobs:
path: ~/junit
- store_artifacts:
path: ~/junit
- run:
name: Upload FOSSA analysis (from master only)
command: |
if [[ ( -n "$FOSSA_API_KEY" ) && ( "$CIRCLE_BRANCH" == "master" ) ]]; then
curl -s -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | sudo bash;
fossa init;
FOSSA_API_KEY=$FOSSA_API_KEY fossa;
fi
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

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

## [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.
- Exception stacktraces are now logged only at DEBUG level. Previously, some were being logged at ERROR level.

## [4.2.1] - 2018-07-16
### Fixed:
- Should not permanently give up on posting events if the server returns a 400 error.
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.1
version=4.2.2
ossrhUsername=
ossrhPassword=
6 changes: 3 additions & 3 deletions src/main/java/com/launchdarkly/client/Clause.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ boolean matchesUserNoSegments(LDUser user) {
JsonArray array = userValue.getAsJsonArray();
for (JsonElement jsonElement : array) {
if (!jsonElement.isJsonPrimitive()) {
logger.error("Invalid custom attribute value in user object: " + jsonElement);
logger.error("Invalid custom attribute value in user object for user key \"{}\": {}", user.getKey(), jsonElement);
return false;
}
if (matchAny(jsonElement.getAsJsonPrimitive())) {
Expand All @@ -49,8 +49,8 @@ boolean matchesUserNoSegments(LDUser user) {
} else if (userValue.isJsonPrimitive()) {
return maybeNegate(matchAny(userValue.getAsJsonPrimitive()));
}
logger.warn("Got unexpected user attribute type: " + userValue.getClass().getName() + " for user key: "
+ user.getKey() + " and attribute: " + attribute);
logger.warn("Got unexpected user attribute type \"{}\" for user key \"{}\" and attribute \"{}\"",
userValue.getClass().getName(), user.getKey(), attribute);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ private void runMainLoop(BlockingQueue<EventProcessorMessage> inputChannel,
message.completed();
} catch (InterruptedException e) {
} catch (Exception e) {
logger.error("Unexpected error in event processor: " + e);
logger.debug(e.getMessage(), e);
logger.error("Unexpected error in event processor: {}", e.toString());
logger.debug(e.toString(), e);
}
}
}
Expand Down Expand Up @@ -493,8 +493,8 @@ public void run() {
postEvents(eventsOut);
}
} catch (Exception e) {
logger.error("Unexpected error in event processor: " + e);
logger.debug(e.getMessage(), e);
logger.error("Unexpected error in event processor: {}", e.toString());
logger.debug(e.toString(), e);
}
synchronized (activeFlushWorkersCount) {
activeFlushWorkersCount.decrementAndGet();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/launchdarkly/client/FeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EvalResult evaluate(LDUser user, FeatureStore featureStore, EventFactory eventFa
List<Event.FeatureRequest> prereqEvents = new ArrayList<>();

if (user == null || user.getKey() == null) {
logger.warn("Null user or null user key when evaluating flag: " + key + "; returning null");
logger.warn("Null user or null user key when evaluating flag \"{}\"; returning null", key);
return new EvalResult(null, prereqEvents);
}

Expand All @@ -87,7 +87,7 @@ private VariationAndValue evaluate(LDUser user, FeatureStore featureStore, List<
FeatureFlag prereqFeatureFlag = featureStore.get(FEATURES, prereq.getKey());
VariationAndValue prereqEvalResult = null;
if (prereqFeatureFlag == null) {
logger.error("Could not retrieve prerequisite flag: " + prereq.getKey() + " when evaluating: " + key);
logger.error("Could not retrieve prerequisite flag \"{}\" when evaluating \"{}\"", prereq.getKey(), key);
return null;
} else if (prereqFeatureFlag.isOn()) {
prereqEvalResult = prereqFeatureFlag.evaluate(user, featureStore, events, eventFactory);
Expand Down
38 changes: 24 additions & 14 deletions src/main/java/com/launchdarkly/client/LDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public LDClient(String sdkKey, LDConfig config) {
} catch (TimeoutException e) {
logger.error("Timeout encountered waiting for LaunchDarkly client initialization");
} catch (Exception e) {
logger.error("Exception encountered waiting for LaunchDarkly client initialization", e);
logger.error("Exception encountered waiting for LaunchDarkly client initialization: {}", e.toString());
logger.debug(e.toString(), e);
}
if (!updateProcessor.initialized()) {
logger.warn("LaunchDarkly client was not successfully initialized");
Expand Down Expand Up @@ -169,7 +170,8 @@ public Map<String, JsonElement> allFlags(LDUser user) {
result.put(entry.getKey(), evalResult);

} catch (EvaluationException e) {
logger.error("Exception caught when evaluating all flags:", e);
logger.error("Exception caught for feature flag \"{}\" when evaluating all flags: {}", entry.getKey(), e.toString());
logger.debug(e.toString(), e);
}
}
return result;
Expand Down Expand Up @@ -209,9 +211,9 @@ public JsonElement jsonVariation(String featureKey, LDUser user, JsonElement def
public boolean isFlagKnown(String featureKey) {
if (!initialized()) {
if (featureStore.initialized()) {
logger.warn("isFlagKnown called before client initialized for feature flag " + featureKey + "; using last known values from feature store");
logger.warn("isFlagKnown called before client initialized for feature flag \"{}\"; using last known values from feature store", featureKey);
} else {
logger.warn("isFlagKnown called before client initialized for feature flag " + featureKey + "; feature store unavailable, returning false");
logger.warn("isFlagKnown called before client initialized for feature flag \"{}\"; feature store unavailable, returning false", featureKey);
return false;
}
}
Expand All @@ -221,7 +223,8 @@ public boolean isFlagKnown(String featureKey) {
return true;
}
} catch (Exception e) {
logger.error("Encountered exception in LaunchDarkly client", e);
logger.error("Encountered exception while calling isFlagKnown for feature flag \"{}\": {}", e.toString());
logger.debug(e.toString(), e);
}

return false;
Expand All @@ -230,23 +233,24 @@ public boolean isFlagKnown(String featureKey) {
private JsonElement evaluate(String featureKey, LDUser user, JsonElement defaultValue, VariationType expectedType) {
if (!initialized()) {
if (featureStore.initialized()) {
logger.warn("Evaluation called before client initialized for feature flag " + featureKey + "; using last known values from feature store");
logger.warn("Evaluation called before client initialized for feature flag \"{}\"; using last known values from feature store", featureKey);
} else {
logger.warn("Evaluation called before client initialized for feature flag " + featureKey + "; feature store unavailable, returning default value");
logger.warn("Evaluation called before client initialized for feature flag \"{}\"; feature store unavailable, returning default value", featureKey);
sendFlagRequestEvent(eventFactory.newUnknownFeatureRequestEvent(featureKey, user, defaultValue));
return defaultValue;
}
}

FeatureFlag featureFlag = null;
try {
FeatureFlag featureFlag = featureStore.get(FEATURES, featureKey);
featureFlag = featureStore.get(FEATURES, featureKey);
if (featureFlag == null) {
logger.info("Unknown feature flag " + featureKey + "; returning default value");
logger.info("Unknown feature flag \"{}\"; returning default value", featureKey);
sendFlagRequestEvent(eventFactory.newUnknownFeatureRequestEvent(featureKey, user, defaultValue));
return defaultValue;
}
if (user == null || user.getKey() == null) {
logger.warn("Null user or null user key when evaluating flag: " + featureKey + "; returning default value");
logger.warn("Null user or null user key when evaluating flag \"{}\"; returning default value", featureKey);
sendFlagRequestEvent(eventFactory.newDefaultFeatureRequestEvent(featureFlag, user, defaultValue));
return defaultValue;
}
Expand All @@ -266,10 +270,15 @@ private JsonElement evaluate(String featureKey, LDUser user, JsonElement default
return defaultValue;
}
} catch (Exception e) {
logger.error("Encountered exception in LaunchDarkly client", e);
logger.error("Encountered exception while evaluating feature flag \"{}\": {}", featureKey, e.toString());
logger.debug(e.toString(), e);
if (featureFlag == null) {
sendFlagRequestEvent(eventFactory.newUnknownFeatureRequestEvent(featureKey, user, defaultValue));
} else {
sendFlagRequestEvent(eventFactory.newDefaultFeatureRequestEvent(featureFlag, user, defaultValue));
}
return defaultValue;
}
sendFlagRequestEvent(eventFactory.newUnknownFeatureRequestEvent(featureKey, user, defaultValue));
return defaultValue;
}

@Override
Expand Down Expand Up @@ -314,7 +323,8 @@ public String secureModeHash(LDUser user) {
mac.init(new SecretKeySpec(sdkKey.getBytes(), HMAC_ALGORITHM));
return Hex.encodeHexString(mac.doFinal(user.getKeyAsString().getBytes("UTF8")));
} catch (InvalidKeyException | UnsupportedEncodingException | NoSuchAlgorithmException e) {
logger.error("Could not generate secure mode hash", e);
logger.error("Could not generate secure mode hash: {}", e.toString());
logger.debug(e.toString(), e);
}
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/launchdarkly/client/NewRelicReflector.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ static void annotateTransaction(String featureKey, String value) {
try {
addCustomParameter.invoke(null, featureKey, value);
} catch (Exception e) {
logger.error("Unexpected error in LaunchDarkly NewRelic integration");
logger.error("Unexpected error in LaunchDarkly NewRelic integration: {}", e.toString());
logger.debug(e.toString(), e);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/launchdarkly/client/PollingProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void run() {
initFuture.set(null); // if client is initializing, make it stop waiting; has no effect if already inited
}
} catch (IOException e) {
logger.error("Encountered exception in LaunchDarkly client when retrieving update", e);
logger.error("Encountered exception in LaunchDarkly client when retrieving update: {}", e.toString());
logger.debug(e.toString(), e);
}
}
}, 0L, config.pollingIntervalMillis, TimeUnit.MILLISECONDS);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/launchdarkly/client/StreamProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public void onMessage(String name, MessageEvent event) throws Exception {
logger.info("Initialized LaunchDarkly client.");
}
} catch (IOException e) {
logger.error("Encountered exception in LaunchDarkly client", e);
logger.error("Encountered exception in LaunchDarkly client: {}", e.toString());
logger.debug(e.toString(), e);
}
break;
case INDIRECT_PATCH:
Expand All @@ -151,7 +152,8 @@ public void onMessage(String name, MessageEvent event) throws Exception {
}
}
} catch (IOException e) {
logger.error("Encountered exception in LaunchDarkly client", e);
logger.error("Encountered exception in LaunchDarkly client: {}", e.toString());
logger.debug(e.toString(), e);
}
break;
default:
Expand All @@ -167,8 +169,8 @@ public void onComment(String comment) {

@Override
public void onError(Throwable throwable) {
logger.error("Encountered EventSource error: " + throwable.getMessage());
logger.debug("", throwable);
logger.error("Encountered EventSource error: {}" + throwable.toString());
logger.debug(throwable.toString(), throwable);
}
};

Expand Down