Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #72 #73

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
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
Loading