Skip to content

Commit

Permalink
fix multiple circular logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan-Kim committed Jun 21, 2024
1 parent 81b9295 commit 819e5e1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/src/main/java/growthbook/sdk/java/FeatureEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public <ValueType> FeatureResult<ValueType> evaluateFeature(
Class<ValueType> valueTypeClass,
JsonObject attributeOverrides
) throws ClassCastException {
featureEvalContext.setId(key);

// This callback serves for listening for feature usage events
FeatureUsageCallback featureUsageCallback = context.getFeatureUsageCallback();

Expand All @@ -46,9 +44,14 @@ public <ValueType> FeatureResult<ValueType> evaluateFeature(
.build();

try {
// block that handle recursion
log.info("evaluateFeature: circular dependency detected:");
if (featureEvalContext.getEvaluatedFeatures().contains(key)) {
// block that handle recursion
log.info(
"evaluateFeature: circular dependency detected: {} -> {}. { from: {}, to: {} }",
featureEvalContext.getId(), key,
featureEvalContext.getId(), key
);

FeatureResult<ValueType> featureResultWhenCircularDependencyDetected = FeatureResult
.<ValueType>builder()
.value(null)
Expand All @@ -62,6 +65,7 @@ public <ValueType> FeatureResult<ValueType> evaluateFeature(
}

featureEvalContext.getEvaluatedFeatures().add(key);
featureEvalContext.setId(key);

// Check for feature values forced by URL
if (context.getAllowUrlOverride()) {
Expand Down

0 comments on commit 819e5e1

Please sign in to comment.