11package io .split .engine .experiments ;
22
3+ import io .split .client .dtos .ChangeDto ;
4+ import io .split .client .dtos .RuleBasedSegment ;
5+ import io .split .client .dtos .Split ;
36import io .split .client .dtos .SplitChange ;
47import io .split .client .exceptions .UriTooLongException ;
58import io .split .client .interceptors .FlagSetsFilter ;
@@ -121,7 +124,7 @@ private Set<String> runWithoutExceptionHandling(FetchOptions options) throws Int
121124 throw new IllegalStateException ("SplitChange was null" );
122125 }
123126
124- if (checkExitConditions (change .featureFlags , _splitCacheProducer .getChangeNumber ()) &&
127+ if (checkExitConditions (change .featureFlags , _splitCacheProducer .getChangeNumber ()) ||
125128 checkExitConditions (change .ruleBasedSegments , _ruleBasedSegmentCacheProducer .getChangeNumber ())) {
126129 return segments ;
127130 }
@@ -137,11 +140,12 @@ private Set<String> runWithoutExceptionHandling(FetchOptions options) throws Int
137140 if (change .featureFlags .d .isEmpty () && change .ruleBasedSegments .d .isEmpty ()) {
138141 return segments ;
139142 }
140- }
143+
141144
142145 synchronized (_lock ) {
143146 // check state one more time.
144- if (checkReturnConditions (change )) {
147+ if (checkExitConditions (change .featureFlags , _splitCacheProducer .getChangeNumber ()) &&
148+ checkExitConditions (change .ruleBasedSegments , _ruleBasedSegmentCacheProducer .getChangeNumber ())) {
145149 // some other thread may have updated the shared state. exit
146150 return segments ;
147151 }
@@ -156,16 +160,11 @@ private Set<String> runWithoutExceptionHandling(FetchOptions options) throws Int
156160 ruleBasedSegmentsToUpdate .getToRemove (), change .ruleBasedSegments .t );
157161 _telemetryRuntimeProducer .recordSuccessfulSync (LastSynchronizationRecordsEnum .SPLITS , System .currentTimeMillis ());
158162 }
163+
159164 return segments ;
160165 }
161166
162167 private <T > boolean checkExitConditions (ChangeDto <T > change , long cn ) {
163168 return change .s != cn || change .t < cn ;
164169 }
165-
166- private boolean checkReturnConditions (SplitChange change ) {
167- return ((change .featureFlags .s != _splitCacheProducer .getChangeNumber () || change .featureFlags .t < _splitCacheProducer .getChangeNumber ()) &&
168- (change .ruleBasedSegments .s != _ruleBasedSegmentCacheProducer .getChangeNumber () ||
169- change .ruleBasedSegments .t < _ruleBasedSegmentCacheProducer .getChangeNumber ()));
170- }
171170}
0 commit comments