@@ -88,8 +88,8 @@ private List<String> getFeatureFlagNamesByFlagSets(List<String> flagSets) {
88
88
private TreatmentLabelAndChangeNumber getTreatment (String matchingKey , String bucketingKey , ParsedSplit parsedSplit , Map <String ,
89
89
Object > attributes ) throws ChangeNumberExceptionWrapper {
90
90
try {
91
+ String config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (parsedSplit .defaultTreatment ()) : null ;
91
92
if (parsedSplit .killed ()) {
92
- String config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (parsedSplit .defaultTreatment ()) : null ;
93
93
return new TreatmentLabelAndChangeNumber (
94
94
parsedSplit .defaultTreatment (),
95
95
Labels .KILLED ,
@@ -98,6 +98,17 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
98
98
parsedSplit .impressionsDisabled ());
99
99
}
100
100
101
+ String bk = (bucketingKey == null ) ? matchingKey : bucketingKey ;
102
+
103
+ if (!parsedSplit .prerequisites ().match (matchingKey , bk , attributes , _evaluationContext )) {
104
+ return new TreatmentLabelAndChangeNumber (
105
+ parsedSplit .defaultTreatment (),
106
+ Labels .PREREQUISITES_NOT_MET ,
107
+ parsedSplit .changeNumber (),
108
+ config ,
109
+ parsedSplit .impressionsDisabled ());
110
+ }
111
+
101
112
/*
102
113
* There are three parts to a single Feature flag: 1) Whitelists 2) Traffic Allocation
103
114
* 3) Rollout. The flag inRollout is there to understand when we move into the Rollout
@@ -106,8 +117,6 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
106
117
*/
107
118
boolean inRollout = false ;
108
119
109
- String bk = (bucketingKey == null ) ? matchingKey : bucketingKey ;
110
-
111
120
for (ParsedCondition parsedCondition : parsedSplit .parsedConditions ()) {
112
121
113
122
if (!inRollout && parsedCondition .conditionType () == ConditionType .ROLLOUT ) {
@@ -118,7 +127,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
118
127
119
128
if (bucket > parsedSplit .trafficAllocation ()) {
120
129
// out of split
121
- String config = parsedSplit .configurations () != null ?
130
+ config = parsedSplit .configurations () != null ?
122
131
parsedSplit .configurations ().get (parsedSplit .defaultTreatment ()) : null ;
123
132
return new TreatmentLabelAndChangeNumber (parsedSplit .defaultTreatment (), Labels .NOT_IN_SPLIT ,
124
133
parsedSplit .changeNumber (), config , parsedSplit .impressionsDisabled ());
@@ -130,7 +139,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
130
139
131
140
if (parsedCondition .matcher ().match (matchingKey , bucketingKey , attributes , _evaluationContext )) {
132
141
String treatment = Splitter .getTreatment (bk , parsedSplit .seed (), parsedCondition .partitions (), parsedSplit .algo ());
133
- String config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (treatment ) : null ;
142
+ config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (treatment ) : null ;
134
143
return new TreatmentLabelAndChangeNumber (
135
144
treatment ,
136
145
parsedCondition .label (),
@@ -140,7 +149,7 @@ private TreatmentLabelAndChangeNumber getTreatment(String matchingKey, String bu
140
149
}
141
150
}
142
151
143
- String config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (parsedSplit .defaultTreatment ()) : null ;
152
+ config = parsedSplit .configurations () != null ? parsedSplit .configurations ().get (parsedSplit .defaultTreatment ()) : null ;
144
153
return new TreatmentLabelAndChangeNumber (
145
154
parsedSplit .defaultTreatment (),
146
155
Labels .DEFAULT_RULE ,
@@ -158,7 +167,6 @@ private TreatmentLabelAndChangeNumber evaluateParsedSplit(String matchingKey, St
158
167
if (parsedSplit == null ) {
159
168
return new TreatmentLabelAndChangeNumber (Treatments .CONTROL , Labels .DEFINITION_NOT_FOUND );
160
169
}
161
-
162
170
return getTreatment (matchingKey , bucketingKey , parsedSplit , attributes );
163
171
} catch (ChangeNumberExceptionWrapper e ) {
164
172
_log .error ("Evaluator Exception" , e .wrappedException ());
0 commit comments