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
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
9 changes: 8 additions & 1 deletion src/main/java/com/launchdarkly/client/LDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,14 @@ private boolean evaluate(String featureKey, LDUser user, boolean defaultValue) {

try {
FeatureRep<Boolean> result = (FeatureRep<Boolean>) config.featureStore.get(featureKey);
if (result == null) {
if (result != null) {
if (config.stream && config.debugStreaming) {
FeatureRep<Boolean> pollingResult = requestor.makeRequest(featureKey, true);
if (!result.equals(pollingResult)) {
logger.warn("Mismatch between streaming and polling feature! Streaming: {} Polling: {}", result, pollingResult);
}
}
} else {
logger.warn("Unknown feature flag " + featureKey + "; returning default value: ");
return defaultValue;
}
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/com/launchdarkly/client/Variation.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ public boolean equals(Object o) {
Variation<?> variation = (Variation<?>) o;

if (weight != variation.weight) return false;
if (!value.equals(variation.value)) return false;
if (!userTarget.equals(variation.userTarget)) return false;
return targets.equals(variation.targets);

if (value != null ? !value.equals(variation.value) : variation.value != null) return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the old equals() and hashCode() methods and told IntelliJ to autogen new ones with null checking.

if (userTarget != null ? !userTarget.equals(variation.userTarget) : variation.userTarget != null) return false;
return targets != null ? targets.equals(variation.targets) : variation.targets == null;
}

@Override
public int hashCode() {
int result = value.hashCode();
int result = value != null ? value.hashCode() : 0;
result = 31 * result + weight;
result = 31 * result + userTarget.hashCode();
result = 31 * result + targets.hashCode();
result = 31 * result + (userTarget != null ? userTarget.hashCode() : 0);
result = 31 * result + (targets != null ? targets.hashCode() : 0);
return result;
}

Expand Down