Skip to content

Commit af65cdc

Browse files
committed
fixing excluded segments
1 parent 8431b8d commit af65cdc

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

client/src/main/java/io/split/client/dtos/RuleBasedSegment.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public String toString() {
1818
", status=" + status +
1919
", trafficTypeName='" + trafficTypeName + '\'' +
2020
", changeNumber=" + changeNumber +
21-
", excluded.keys=" + Arrays.toString(excluded.keys.stream().toArray()) +
22-
", excluded.segments=" + Arrays.toString(excluded.segments.stream().toArray()) +
2321
'}';
2422
}
2523
}

client/src/main/java/io/split/engine/matchers/RuleBasedSegmentMatcher.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
public class RuleBasedSegmentMatcher implements Matcher {
2121
private final String standardType = "standard";
22+
private final String ruleBasedType = "rule-based";
2223

2324
private final String _segmentName;
2425

@@ -44,8 +45,19 @@ public boolean match(Object matchValue, String bucketingKey, Map<String, Object>
4445
if (segment.type.equals(standardType) && evaluationContext.getSegmentCache().isInSegment(segment.name, (String) matchValue)) {
4546
return false;
4647
}
48+
49+
if (segment.type.equals(ruleBasedType)) {
50+
List<ParsedCondition> conditions = evaluationContext.getRuleBasedSegmentCache().get(segment.name).parsedConditions();
51+
if (matchConditions(conditions, matchValue, bucketingKey, attributes, evaluationContext)) {
52+
return true;
53+
}
54+
}
4755
}
48-
List<ParsedCondition> conditions = parsedRuleBasedSegment.parsedConditions();
56+
57+
return matchConditions(parsedRuleBasedSegment.parsedConditions(), matchValue, bucketingKey, attributes, evaluationContext);
58+
}
59+
60+
private boolean matchConditions(List<ParsedCondition> conditions, Object matchValue, String bucketingKey, Map<String, Object> attributes, EvaluationContext evaluationContext) {
4961
for (ParsedCondition parsedCondition : conditions) {
5062
if (parsedCondition.matcher().match((String) matchValue, bucketingKey, attributes, evaluationContext)) {
5163
return true;

0 commit comments

Comments
 (0)