@@ -48,6 +48,7 @@ public final class SplitClientImpl implements SplitClient {
4848 public static final SplitResult SPLIT_RESULT_CONTROL = new SplitResult (Treatments .CONTROL , null );
4949 private static final String CLIENT_DESTROY = "Client has already been destroyed - no calls possible" ;
5050 private static final String CATCHALL_EXCEPTION = "CatchAll Exception" ;
51+ private static final String MATCHING_KEY = "matchingKey" ;
5152
5253 private static final Logger _log = LoggerFactory .getLogger (SplitClientImpl .class );
5354
@@ -321,7 +322,7 @@ private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bu
321322 return SPLIT_RESULT_CONTROL ;
322323 }
323324
324- if (!KeyValidator .isValid (matchingKey , "matchingKey" , _config .maxStringLength (), methodEnum .getMethod ())) {
325+ if (!KeyValidator .isValid (matchingKey , MATCHING_KEY , _config .maxStringLength (), methodEnum .getMethod ())) {
325326 return SPLIT_RESULT_CONTROL ;
326327 }
327328
@@ -414,8 +415,7 @@ private Map<String, SplitResult> getTreatmentsBySetsWithConfigInternal(String ma
414415 List <String > featureFlagNames = new ArrayList <>();
415416 try {
416417 checkSDKReady (methodEnum );
417- featureFlagNames = getAllFlags (cleanFlagSets );
418- Map <String , SplitResult > result = validateBeforeEvaluate (featureFlagNames , matchingKey , methodEnum ,bucketingKey );
418+ Map <String , SplitResult > result = validateBeforeEvaluateByFlagSets (matchingKey , methodEnum ,bucketingKey );
419419 if (result != null ) {
420420 return result ;
421421 }
@@ -432,7 +432,6 @@ private Map<String, SplitResult> getTreatmentsBySetsWithConfigInternal(String ma
432432 return createMapControl (featureFlagNames );
433433 }
434434 }
435-
436435 private Map <String , SplitResult > processEvaluatorResult (Map <String , EvaluatorImp .TreatmentLabelAndChangeNumber > evaluatorResult ,
437436 MethodEnum methodEnum , String matchingKey , String bucketingKey , Map <String ,
438437 Object > attributes , long initTime ){
@@ -457,13 +456,28 @@ private Map<String, SplitResult> processEvaluatorResult(Map<String, EvaluatorImp
457456 return result ;
458457 }
459458
459+ private Map <String , SplitResult > validateBeforeEvaluateByFlagSets (String matchingKey , MethodEnum methodEnum ,
460+ String bucketingKey ) {
461+ if (_container .isDestroyed ()) {
462+ _log .error (CLIENT_DESTROY );
463+ return new HashMap <>();
464+ }
465+ if (!KeyValidator .isValid (matchingKey , MATCHING_KEY , _config .maxStringLength (), methodEnum .getMethod ())) {
466+ return new HashMap <>();
467+ }
468+ if (!KeyValidator .bucketingKeyIsValid (bucketingKey , _config .maxStringLength (), methodEnum .getMethod ())) {
469+ return new HashMap <>();
470+ }
471+ return null ;
472+ }
473+
460474 private Map <String , SplitResult > validateBeforeEvaluate (List <String > featureFlagNames , String matchingKey , MethodEnum methodEnum ,
461475 String bucketingKey ) {
462476 if (_container .isDestroyed ()) {
463477 _log .error (CLIENT_DESTROY );
464478 return createMapControl (featureFlagNames );
465479 }
466- if (!KeyValidator .isValid (matchingKey , "matchingKey" , _config .maxStringLength (), methodEnum .getMethod ())) {
480+ if (!KeyValidator .isValid (matchingKey , MATCHING_KEY , _config .maxStringLength (), methodEnum .getMethod ())) {
467481 return createMapControl (featureFlagNames );
468482 }
469483 if (!KeyValidator .bucketingKeyIsValid (bucketingKey , _config .maxStringLength (), methodEnum .getMethod ())) {
@@ -486,16 +500,6 @@ private Set<String> filterSetsAreInConfig(Set<String> sets, MethodEnum methodEnu
486500 }
487501 return setsToReturn ;
488502 }
489-
490- private List <String > getAllFlags (Set <String > sets ) {
491- Map <String , HashSet <String >> namesBySets = _splitCacheConsumer .getNamesByFlagSets (new ArrayList <>(sets ));
492- HashSet <String > flags = new HashSet <>();
493- for (String set : namesBySets .keySet ()) {
494- flags .addAll (namesBySets .get (set ));
495- }
496- return new ArrayList <>(flags );
497- }
498-
499503 private void recordStats (String matchingKey , String bucketingKey , String featureFlagName , long start , String result ,
500504 String operation , String label , Long changeNumber , Map <String , Object > attributes ) {
501505 try {
0 commit comments