Skip to content

Commit 8d4bc04

Browse files
author
Bilal Al
committed
polish
1 parent 4502429 commit 8d4bc04

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ public class Labels {
66
public static final String KILLED = "killed";
77
public static final String DEFINITION_NOT_FOUND = "definition not found";
88
public static final String EXCEPTION = "exception";
9+
public static final String UNSUPPORTED_MATCHER = "unsupported matcher type";
910
}

client/src/main/java/io/split/engine/experiments/SplitParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.split.client.dtos.Split;
99
import io.split.client.dtos.ConditionType;
1010
import io.split.client.dtos.MatcherType;
11+
import io.split.engine.evaluator.Labels;
1112
import io.split.engine.matchers.AllKeysMatcher;
1213
import io.split.engine.matchers.AttributeMatcher;
1314
import io.split.engine.matchers.BetweenMatcher;
@@ -63,6 +64,7 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) {
6364
List<Partition> partitions = condition.partitions;
6465
if (checkUnsupportedMatcherExist(condition.matcherGroup.matchers)) {
6566
_log.error("Unsupported matcher type found for feature flag: " + split.name + " , will revert to default template matcher.");
67+
parsedConditionList.clear();
6668
parsedConditionList.add(getTemplateCondition());
6769
break;
6870
}
@@ -99,7 +101,7 @@ private ParsedCondition getTemplateCondition() {
99101
ConditionType.ROLLOUT,
100102
CombiningMatcher.of(new AllKeysMatcher()),
101103
templatePartitions,
102-
"unsupported matcher type");
104+
Labels.UNSUPPORTED_MATCHER);
103105
}
104106

105107
private CombiningMatcher toMatcher(MatcherGroup matcherGroup) {

client/src/test/java/io/split/engine/experiments/SplitParserTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import io.split.storages.SegmentCache;
66
import io.split.storages.memory.SegmentCacheInMemoryImpl;
77
import io.split.client.dtos.*;
8+
import io.split.engine.evaluator.Labels;
89
import io.split.engine.ConditionsTestUtil;
910
import io.split.engine.SDKReadinessGates;
1011
import io.split.engine.matchers.AttributeMatcher;
@@ -531,6 +532,7 @@ public void contains_string() {
531532
set_matcher_test(c, m);
532533
}
533534

535+
@Test
534536
public void unsupportedMatcher() {
535537
SplitParser parser = new SplitParser();
536538
String splitWithUndefinedMatcher = "{\"since\":-1,\"till\": 1457726098069,\"splits\": [{ \"changeNumber\": 123, \"trafficTypeName\": \"user\", \"name\": \"some_name\","
@@ -544,6 +546,7 @@ public void unsupportedMatcher() {
544546
// should not cause exception
545547
ParsedSplit parsedSplit = parser.parse(split);
546548
for (ParsedCondition parsedCondition : parsedSplit.parsedConditions()) {
549+
assertTrue(parsedCondition.label() == Labels.UNSUPPORTED_MATCHER);
547550
for (AttributeMatcher matcher : parsedCondition.matcher().attributeMatchers()) {
548551
// Check the matcher is ALL_KEYS
549552
assertTrue(matcher.matcher().toString().equals(" in segment all"));

0 commit comments

Comments
 (0)