Skip to content

Commit a639d54

Browse files
committed
polishing
1 parent c26b3fa commit a639d54

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

client/src/main/java/io/split/client/SplitClientImpl.java

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -610,46 +610,43 @@ private Map<String, SplitResult> getTreatmentsBySetsWithConfigInternal(String ma
610610
if (cleanFlagSets.isEmpty()) {
611611
return new HashMap<>();
612612
}
613-
List<String> featureFlagNames = new ArrayList<>();
614-
try {
615-
checkSDKReady(methodEnum);
616-
Map<String, SplitResult> result = validateBeforeEvaluateByFlagSets(matchingKey, methodEnum,bucketingKey);
617-
if(result != null) {
618-
return result;
619-
}
620-
Map<String, EvaluatorImp.TreatmentLabelAndChangeNumber> evaluatorResult = _evaluator.evaluateFeaturesByFlagSets(matchingKey,
621-
bucketingKey, new ArrayList<>(cleanFlagSets), attributes);
613+
checkSDKReady(methodEnum);
614+
Map<String, SplitResult> result = validateBeforeEvaluateByFlagSets(matchingKey, methodEnum,bucketingKey);
615+
if(result != null) {
616+
return result;
617+
}
618+
Map<String, EvaluatorImp.TreatmentLabelAndChangeNumber> evaluatorResult = _evaluator.evaluateFeaturesByFlagSets(matchingKey,
619+
bucketingKey, new ArrayList<>(cleanFlagSets), attributes);
622620

623-
return processEvaluatorResult(evaluatorResult, methodEnum, matchingKey, bucketingKey, attributes, initTime,
624-
validateProperties(evaluationOptions.getProperties()));
625-
} catch (Exception e) {
626-
try {
621+
evaluatorResult.entrySet().forEach(flag -> {
622+
if (flag.getValue().label != null &&
623+
flag.getValue().label.contains(io.split.engine.evaluator.Labels.EXCEPTION)) {
627624
_telemetryEvaluationProducer.recordException(methodEnum);
628-
_log.error(CATCHALL_EXCEPTION, e);
629-
} catch (Exception e1) {
630-
// ignore
631625
}
632-
return createMapControl(featureFlagNames);
633-
}
626+
});
627+
return processEvaluatorResult(evaluatorResult, methodEnum, matchingKey, bucketingKey, attributes, initTime,
628+
validateProperties(evaluationOptions.getProperties()));
634629
}
635630

636631
private Map<String, SplitResult> processEvaluatorResult(Map<String, EvaluatorImp.TreatmentLabelAndChangeNumber> evaluatorResult,
637632
MethodEnum methodEnum, String matchingKey, String bucketingKey, Map<String,
638633
Object> attributes, long initTime, String properties){
639634
List<DecoratedImpression> decoratedImpressions = new ArrayList<>();
640635
Map<String, SplitResult> result = new HashMap<>();
641-
evaluatorResult.keySet().forEach(t -> {
642-
if (evaluatorResult.get(t).label != null && evaluatorResult.get(t).label.contains(Labels.DEFINITION_NOT_FOUND) && _gates.isSDKReady()) {
636+
evaluatorResult.keySet().forEach(flag -> {
637+
if (evaluatorResult.get(flag).label != null &&
638+
evaluatorResult.get(flag).label.contains(Labels.DEFINITION_NOT_FOUND) &&
639+
_gates.isSDKReady()) {
643640
_log.warn(String.format("%s: you passed \"%s\" that does not exist in this environment please double check " +
644-
"what feature flags exist in the Split user interface.", methodEnum.getMethod(), t));
645-
result.put(t, checkFallbackTreatment(t));
641+
"what feature flags exist in the Split user interface.", methodEnum.getMethod(), flag));
642+
result.put(flag, checkFallbackTreatment(flag));
646643
} else {
647-
result.put(t, new SplitResult(evaluatorResult.get(t).treatment, evaluatorResult.get(t).configurations));
644+
result.put(flag, new SplitResult(evaluatorResult.get(flag).treatment, evaluatorResult.get(flag).configurations));
648645
decoratedImpressions.add(
649646
new DecoratedImpression(
650-
new Impression(matchingKey, bucketingKey, t, evaluatorResult.get(t).treatment, System.currentTimeMillis(),
651-
evaluatorResult.get(t).label, evaluatorResult.get(t).changeNumber, attributes, properties),
652-
evaluatorResult.get(t).track));
647+
new Impression(matchingKey, bucketingKey, flag, evaluatorResult.get(flag).treatment, System.currentTimeMillis(),
648+
evaluatorResult.get(flag).label, evaluatorResult.get(flag).changeNumber, attributes, properties),
649+
evaluatorResult.get(flag).track));
653650
}
654651
});
655652
_telemetryEvaluationProducer.recordLatency(methodEnum, System.currentTimeMillis() - initTime);

client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Map<String, EvaluatorImp.TreatmentLabelAndChangeNumber> evaluateFeaturesB
6565
return evaluateFeatures(key, bucketingKey, flagSetsWithNames, attributes);
6666
} catch (Exception e) {
6767
_log.error("Evaluator Exception", e);
68-
return createMapControl(flagSetsWithNames, "exception");
68+
return createMapControl(flagSetsWithNames, io.split.engine.evaluator.Labels.EXCEPTION);
6969
}
7070
}
7171

0 commit comments

Comments
 (0)