Skip to content

Commit e712e61

Browse files
authored
Merge pull request #464 from splitio/some-fixes-flag-sets
Update version and changelogs
2 parents de89f6c + 2ebec85 commit e712e61

File tree

10 files changed

+36
-28
lines changed

10 files changed

+36
-28
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
4.10.2 (Dec 1, 2023)
2+
- Added getTreatmentsByFlagSets without attributes.
3+
- Fixed some issues for flag sets: Not logging a warning when using flag sets that don't contain cached feature flags.
4+
15
4.10.1 (Nov 9, 2023)
26
- Fixed handler for response http headers.
37

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.split.client</groupId>
77
<artifactId>java-client-parent</artifactId>
8-
<version>4.10.1</version>
8+
<version>4.10.2</version>
99
</parent>
1010
<artifactId>java-client</artifactId>
1111
<packaging>jar</packaging>

client/src/main/java/io/split/client/SplitClientImpl.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private List<String> getFeatureFlagNamesByFlagSets(List<String> flagSets) {
6363
Map<String, HashSet<String>> namesByFlagSets = _splitCacheConsumer.getNamesByFlagSets(flagSets);
6464
for (String set: flagSets) {
6565
HashSet<String> flags = namesByFlagSets.get(set);
66-
if (flags == null) {
66+
if (flags == null || flags.isEmpty()) {
6767
_log.warn(String.format("You passed %s Flag Set that does not contain cached feature flag names, please double check " +
6868
"what Flag Sets are in use in the Split user interface.", set));
6969
continue;

client/src/test/java/io/split/engine/evaluator/EvaluatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ public void evaluateWithWhitelistConditionReturnTreatment() {
153153
@Test
154154
public void evaluateWithSets() {
155155
ParsedSplit split = ParsedSplit.createParsedSplitForTests(SPLIT_NAME, 0, false, DEFAULT_TREATMENT_VALUE, _conditions, TRAFFIC_TYPE_VALUE, CHANGE_NUMBER, 2, new HashSet<>(Arrays.asList("set1", "set2")));
156-
List<String> sets = new ArrayList<>(Arrays.asList("set1"));
156+
List<String> sets = new ArrayList<>(Arrays.asList("set1", "empty_set"));
157157
Map<String, HashSet<String>> flagSets = new HashMap<>();
158158
flagSets.put("set1", new HashSet<>(Arrays.asList(SPLIT_NAME)));
159+
flagSets.put("empty_set", null);
159160
Mockito.when(_splitCacheConsumer.getNamesByFlagSets(sets)).thenReturn(flagSets);
160161
Map<String, ParsedSplit> parsedSplits = new HashMap<>();
161162
parsedSplits.put(SPLIT_NAME, split);

client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.stream.Collectors;
2424
import java.util.stream.Stream;
2525

26+
import static org.junit.Assert.assertEquals;
2627
import static org.junit.Assert.assertFalse;
2728
import static org.junit.Assert.assertNull;
2829
import static org.junit.Assert.assertTrue;
@@ -236,5 +237,9 @@ public void testGetNamesByFlagSets() {
236237
_cache.remove("splitName_2");
237238
namesByFlagSets = _cache.getNamesByFlagSets(new ArrayList<>(Arrays.asList("set1", "set2", "set3")));
238239
assertFalse(namesByFlagSets.get("set1").contains("splitName_2"));
240+
_cache.remove("splitName_1");
241+
namesByFlagSets = _cache.getNamesByFlagSets(new ArrayList<>(Arrays.asList("set1", "set2", "set3")));
242+
assertFalse(namesByFlagSets.get("set1").contains("splitName_1"));
243+
assertTrue(namesByFlagSets.get("set1").isEmpty());
239244
}
240245
}

pluggable-storage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>java-client-parent</artifactId>
88
<groupId>io.split.client</groupId>
9-
<version>4.10.1</version>
9+
<version>4.10.2</version>
1010
</parent>
1111

1212
<version>2.1.0</version>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.split.client</groupId>
66
<artifactId>java-client-parent</artifactId>
7-
<version>4.10.1</version>
7+
<version>4.10.2</version>
88
<dependencyManagement>
99
<dependencies>
1010
<dependency>

redis-wrapper/pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>java-client-parent</artifactId>
88
<groupId>io.split.client</groupId>
9-
<version>4.10.1</version>
9+
<version>4.10.2</version>
1010
</parent>
1111
<artifactId>redis-wrapper</artifactId>
1212
<version>3.1.0</version>
@@ -35,12 +35,6 @@
3535
<artifactId>junit</artifactId>
3636
<scope>test</scope>
3737
</dependency>
38-
<dependency>
39-
<groupId>io.split.client</groupId>
40-
<artifactId>pluggable-storage</artifactId>
41-
<version>2.1.0</version>
42-
<scope>compile</scope>
43-
</dependency>
4438
</dependencies>
4539

4640
<profiles>

testing/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>io.split.client</groupId>
77
<artifactId>java-client-parent</artifactId>
8-
<version>4.10.1</version>
8+
<version>4.10.2</version>
99
</parent>
1010
<artifactId>java-client-testing</artifactId>
1111
<packaging>jar</packaging>

0 commit comments

Comments
 (0)