11package io .split .engine .experiments ;
22
33import com .google .common .collect .Lists ;
4- import io .split .client .dtos .Condition ;
5- import io .split .client .dtos .Matcher ;
6- import io .split .client .dtos .MatcherGroup ;
7- import io .split .client .dtos .Partition ;
8- import io .split .client .dtos .Split ;
4+ import io .split .client .dtos .*;
95import io .split .engine .matchers .AllKeysMatcher ;
106import io .split .engine .matchers .AttributeMatcher ;
117import io .split .engine .matchers .BetweenMatcher ;
@@ -59,6 +55,11 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) {
5955
6056 for (Condition condition : split .conditions ) {
6157 List <Partition > partitions = condition .partitions ;
58+ if (checkUnsupportedMatcherExist (condition .matcherGroup .matchers )) {
59+ _log .error ("Unsupported matcher type found for feature flag: " + split .name + " , will revert to default template matcher." );
60+ parsedConditionList .add (getTemplateCondition ());
61+ break ;
62+ }
6263 CombiningMatcher matcher = toMatcher (condition .matcherGroup );
6364 parsedConditionList .add (new ParsedCondition (condition .conditionType , matcher , partitions , condition .label ));
6465 }
@@ -67,6 +68,31 @@ private ParsedSplit parseWithoutExceptionHandling(Split split) {
6768 split .changeNumber , split .trafficAllocation , split .trafficAllocationSeed , split .algo , split .configurations , split .sets );
6869 }
6970
71+ private boolean checkUnsupportedMatcherExist (List <io .split .client .dtos .Matcher > matchers ) {
72+ for (io .split .client .dtos .Matcher matcher : matchers ) {
73+ try {
74+ matcher .matcherType .equals (null );
75+ } catch (NullPointerException e ) {
76+ // If the exception is caught, it means unsupported matcher
77+ return true ;
78+ }
79+ }
80+ return false ;
81+ }
82+
83+ private ParsedCondition getTemplateCondition () {
84+ List <Partition > templatePartitions = Lists .newArrayList ();
85+ Partition partition = new Partition ();
86+ partition .treatment = "control" ;
87+ partition .size = 100 ;
88+ templatePartitions .add (partition );
89+ return new ParsedCondition (
90+ ConditionType .ROLLOUT ,
91+ CombiningMatcher .of (new AllKeysMatcher ()),
92+ templatePartitions ,
93+ "unsupported matcher type" );
94+ }
95+
7096 private CombiningMatcher toMatcher (MatcherGroup matcherGroup ) {
7197 List <io .split .client .dtos .Matcher > matchers = matcherGroup .matchers ;
7298 checkArgument (!matchers .isEmpty ());
0 commit comments