From 918d664624d7ae9c664185b4a9132041d6fcee58 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Wed, 29 Nov 2023 10:01:56 -0300 Subject: [PATCH 1/9] [SDKS-7788] Some flag set fixes --- .../java/io/split/client/SplitClient.java | 65 ++++++++++++++++++- .../java/io/split/client/SplitClientImpl.java | 33 +++++++++- .../inputValidation/FlagSetsValidator.java | 2 +- .../storages/memory/InMemoryCacheImp.java | 4 +- .../io/split/client/SplitClientImplTest.java | 2 +- .../storages/memory/InMemoryCacheTest.java | 4 +- .../client/testing/SplitClientForTest.java | 20 ++++++ 7 files changed, 119 insertions(+), 11 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitClient.java b/client/src/main/java/io/split/client/SplitClient.java index e997be448..a07718b1f 100644 --- a/client/src/main/java/io/split/client/SplitClient.java +++ b/client/src/main/java/io/split/client/SplitClient.java @@ -256,7 +256,7 @@ public interface SplitClient { Map getTreatmentsWithConfig(String key, List featureFlagNames, Map attributes); /** - * Same as {@link #getTreatments(Key, List, Map)} but it returns for each feature flag the configuration associated to the + * Same as {@link #getTreatments(Key, List, Map)} but it returns for each feature flag the configuration associated to the * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. * * @param key the matching and bucketing keys. MUST NOT be null. @@ -268,6 +268,21 @@ public interface SplitClient { */ Map getTreatmentsWithConfig(Key key, List featureFlagNames, Map attributes); + /** + * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the + * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. + *

+ *

+ * Examples include showing a different treatment to users on trial plan + * vs. premium plan. Another example is to show a different treatment + * to users created after a certain date. + * + * @param key a unique key of your customer (e.g. user_id, user_email, account_id, etc.) MUST not be null or empty. + * @param flagSet the Flag Set name that you want to evaluate. MUST not be null or empty. + * @return for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'. + */ + Map getTreatmentsByFlagSet(String key, String flagSet); + /** * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. @@ -300,6 +315,21 @@ public interface SplitClient { */ Map getTreatmentsByFlagSet(Key key, String flagSet, Map attributes); + /** + * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the + * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. + *

+ *

+ * Examples include showing a different treatment to users on trial plan + * vs. premium plan. Another example is to show a different treatment + * to users created after a certain date. + * + * @param key a unique key of your customer (e.g. user_id, user_email, account_id, etc.) MUST not be null or empty. + * @param flagSets the names of Flag Sets that you want to evaluate. MUST not be null or empty. + * @return for each feature flag the evaluated treatment, the default treatment of this feature flag, or 'control'. + */ + Map getTreatmentsByFlagSets(String key, List flagSets); + /** * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. @@ -332,6 +362,22 @@ public interface SplitClient { */ Map getTreatmentsByFlagSets(Key key, List flagSets, Map attributes); + /** + * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the + * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. + *

+ *

+ * Examples include showing a different treatment to users on trial plan + * vs. premium plan. Another example is to show a different treatment + * to users created after a certain date. + * + * @param key a unique key of your customer (e.g. user_id, user_email, account_id, etc.) MUST not be null or empty. + * @param flagSet the Flag Set name that you want to evaluate. MUST not be null or empty. + * @return for each feature flag the evaluated treatment (the default treatment of this feature flag, or 'control') and a configuration + * associated to this treatment if set. + */ + Map getTreatmentsWithConfigByFlagSet(String key, String flagSet); + /** * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. @@ -366,6 +412,22 @@ public interface SplitClient { */ Map getTreatmentsWithConfigByFlagSet(Key key, String flagSet, Map attributes); + /** + * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the + * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. + *

+ *

+ * Examples include showing a different treatment to users on trial plan + * vs. premium plan. Another example is to show a different treatment + * to users created after a certain date. + * + * @param key a unique key of your customer (e.g. user_id, user_email, account_id, etc.) MUST not be null or empty. + * @param flagSets the names of Flag Sets that you want to evaluate. MUST not be null or empty. + * @return for each feature flag the evaluated treatment (the default treatment of this feature flag, or 'control') and a configuration + * associated to this treatment if set. + */ + Map getTreatmentsWithConfigByFlagSets(String key, List flagSets); + /** * Same as {@link #getTreatments(String, List, Map)} but it returns for each feature flag the configuration associated to the * matching treatment if any. Otherwise {@link SplitResult.configurations()} will be null. @@ -444,7 +506,6 @@ public interface SplitClient { * @param key the identifier of the entity * @param trafficType the type of the event * @param eventType the type of the event - * @param value the value of the event * * @return true if the track was successful, false otherwise */ diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index 5ac3f934c..08e7beaa6 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -150,6 +150,13 @@ public Map getTreatmentsWithConfig(Key key, List fe MethodEnum.TREATMENTS_WITH_CONFIG); } + @Override + public Map getTreatmentsByFlagSet(String key, String flagSet) { + return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)), + null, MethodEnum.TREATMENTS_BY_FLAG_SET).entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment())); + } + @Override public Map getTreatmentsByFlagSet(String key, String flagSet, Map attributes) { return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)), @@ -164,6 +171,13 @@ public Map getTreatmentsByFlagSet(Key key, String flagSet, Map e.getValue().treatment())); } + @Override + public Map getTreatmentsByFlagSets(String key, List flagSets) { + return getTreatmentsBySetsWithConfigInternal(key, null, flagSets, + null, MethodEnum.TREATMENTS_BY_FLAG_SETS).entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment())); + } + @Override public Map getTreatmentsByFlagSets(String key, List flagSets, Map attributes) { return getTreatmentsBySetsWithConfigInternal(key, null, flagSets, @@ -178,6 +192,12 @@ public Map getTreatmentsByFlagSets(Key key, List flagSet .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().treatment())); } + @Override + public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet) { + return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)), + null, MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SET); + } + @Override public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet, Map attributes) { return getTreatmentsBySetsWithConfigInternal(key, null, new ArrayList<>(Arrays.asList(flagSet)), @@ -190,6 +210,12 @@ public Map getTreatmentsWithConfigByFlagSet(Key key, String attributes, MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SET); } + @Override + public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets) { + return getTreatmentsBySetsWithConfigInternal(key, null, flagSets, + null, MethodEnum.TREATMENTS_WITH_CONFIG_BY_FLAG_SETS); + } + @Override public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets, Map attributes) { return getTreatmentsBySetsWithConfigInternal(key, null, flagSets, @@ -381,7 +407,8 @@ private Map getTreatmentsBySetsWithConfigInternal(String ma return new HashMap<>(); } Set cleanFlagSets = cleanup(sets); - if (filterSetsAreInConfig(cleanFlagSets, methodEnum).isEmpty()) { + cleanFlagSets = filterSetsAreInConfig(cleanFlagSets, methodEnum); + if (cleanFlagSets.isEmpty()) { return new HashMap<>(); } List featureFlagNames = new ArrayList<>(); @@ -447,8 +474,8 @@ private Map validateBeforeEvaluate(List featureFlag } return null; } - private List filterSetsAreInConfig(Set sets, MethodEnum methodEnum) { - List setsToReturn = new ArrayList<>(); + private Set filterSetsAreInConfig(Set sets, MethodEnum methodEnum) { + Set setsToReturn = new HashSet<>(); for (String set : sets) { if (!_flagSetsFilter.intersect(set)) { _log.warn(String.format("%s: you passed %s which is not part of the configured FlagSetsFilter, " + diff --git a/client/src/main/java/io/split/inputValidation/FlagSetsValidator.java b/client/src/main/java/io/split/inputValidation/FlagSetsValidator.java index 4efccb0b8..6b6df2d88 100644 --- a/client/src/main/java/io/split/inputValidation/FlagSetsValidator.java +++ b/client/src/main/java/io/split/inputValidation/FlagSetsValidator.java @@ -33,7 +33,7 @@ public static Set cleanup(List flagSets) { } if (!Pattern.matches(FLAG_SET_REGEX, flagSet)) { _log.warn(String.format("you passed %s, Flag Set must adhere to the regular expressions %s. This means a Flag Set must be " + - "start with a letter, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.", + "start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.", flagSet, FLAG_SET_REGEX, flagSet)); continue; } diff --git a/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java b/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java index 7920a6af0..62baaf44b 100644 --- a/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java +++ b/client/src/main/java/io/split/storages/memory/InMemoryCacheImp.java @@ -110,9 +110,7 @@ public Map> getNamesByFlagSets(List flagSets) { Map> toReturn = new HashMap<>(); for (String set: flagSets) { HashSet keys = _flagSets.get(set); - if(keys != null){ - toReturn.put(set, keys); - } + toReturn.put(set, keys); } return toReturn; } diff --git a/client/src/test/java/io/split/client/SplitClientImplTest.java b/client/src/test/java/io/split/client/SplitClientImplTest.java index 59d5cc066..4210b9782 100644 --- a/client/src/test/java/io/split/client/SplitClientImplTest.java +++ b/client/src/test/java/io/split/client/SplitClientImplTest.java @@ -1955,7 +1955,7 @@ public void testTreatmentsByFlagSets() { fetchManyResult.put(test2, parsedSplit2); when(splitCacheConsumer.fetchMany(new ArrayList<>(Arrays.asList(test2, test)))).thenReturn(fetchManyResult); - List sets = new ArrayList<>(Arrays.asList("set1", "set3")); + List sets = new ArrayList<>(Arrays.asList("set3", "set1")); Map> flagsBySets = new HashMap<>(); flagsBySets.put("set1", new HashSet<>(Arrays.asList(test))); flagsBySets.put("set3", new HashSet<>(Arrays.asList(test2))); diff --git a/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java b/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java index 5a42d2915..ada94588f 100644 --- a/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java +++ b/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public class InMemoryCacheTest { @@ -229,7 +230,8 @@ public void testGetNamesByFlagSets() { assertTrue(namesByFlagSets.get("set1").contains("splitName_2")); assertFalse(namesByFlagSets.get("set1").contains("splitName_3")); assertFalse(namesByFlagSets.get("set1").contains("splitName_4")); - assertFalse(namesByFlagSets.keySet().contains("set3")); + assertTrue(namesByFlagSets.keySet().contains("set3")); + assertNull(namesByFlagSets.get("set3")); _cache.remove("splitName_2"); namesByFlagSets = _cache.getNamesByFlagSets(new ArrayList<>(Arrays.asList("set1", "set2", "set3"))); diff --git a/testing/src/main/java/io/split/client/testing/SplitClientForTest.java b/testing/src/main/java/io/split/client/testing/SplitClientForTest.java index 7fee29996..0c9173457 100644 --- a/testing/src/main/java/io/split/client/testing/SplitClientForTest.java +++ b/testing/src/main/java/io/split/client/testing/SplitClientForTest.java @@ -132,6 +132,11 @@ public Map getTreatmentsWithConfig(Key key, List fe return treatments; } + @Override + public Map getTreatmentsByFlagSet(String key, String flagSet) { + return null; + } + @Override public Map getTreatmentsByFlagSet(String key, String flagSet, Map attributes) { return new HashMap<>(); @@ -142,6 +147,11 @@ public Map getTreatmentsByFlagSet(Key key, String flagSet, Map(); } + @Override + public Map getTreatmentsByFlagSets(String key, List flagSets) { + return null; + } + @Override public Map getTreatmentsByFlagSets(String key, List flagSets, Map attributes) { return new HashMap<>(); @@ -152,6 +162,11 @@ public Map getTreatmentsByFlagSets(Key key, List flagSet return new HashMap<>(); } + @Override + public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet) { + return null; + } + @Override public Map getTreatmentsWithConfigByFlagSet(String key, String flagSet, Map attributes) { return new HashMap<>(); @@ -162,6 +177,11 @@ public Map getTreatmentsWithConfigByFlagSet(Key key, String return new HashMap<>(); } + @Override + public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets) { + return null; + } + @Override public Map getTreatmentsWithConfigByFlagSets(String key, List flagSets, Map attributes) { return new HashMap<>(); From 93873157a416449f16067bd000c6760dbd106640 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 30 Nov 2023 17:43:07 -0300 Subject: [PATCH 2/9] [SDKS-7801] Remove TotalFlagSets and InvalidSets for consumer mode --- .../pluggable/synchronizer/TelemetryConsumerSubmitter.java | 3 --- .../telemetry/synchronizer/HttpTelemetryMemorySender.java | 1 - .../io/split/telemetry/synchronizer/TelemetrySyncTask.java | 1 - .../pluggable/synchronizer/TelemetryConsumerSubmitterTest.java | 2 -- 4 files changed, 7 deletions(-) diff --git a/client/src/main/java/io/split/storages/pluggable/synchronizer/TelemetryConsumerSubmitter.java b/client/src/main/java/io/split/storages/pluggable/synchronizer/TelemetryConsumerSubmitter.java index 61d74bc0a..2e80abdfc 100644 --- a/client/src/main/java/io/split/storages/pluggable/synchronizer/TelemetryConsumerSubmitter.java +++ b/client/src/main/java/io/split/storages/pluggable/synchronizer/TelemetryConsumerSubmitter.java @@ -64,9 +64,6 @@ ConfigConsumer generateConfig(SplitClientConfig splitClientConfig, Map Date: Fri, 1 Dec 2023 10:54:42 -0300 Subject: [PATCH 3/9] Update version and changelogs --- CHANGES.txt | 3 +++ client/pom.xml | 4 ++-- pluggable-storage/pom.xml | 4 ++-- pom.xml | 2 +- redis-wrapper/pom.xml | 10 ++-------- testing/pom.xml | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 5a060d81e..490ee8b0e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +4.10.2 (Dec 1, 2023) +- Fixed some issues for flag sets. + 4.10.1 (Nov 9, 2023) - Fixed handler for response http headers. diff --git a/client/pom.xml b/client/pom.xml index 131bfe230..86b70e9c6 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.1 + 4.10.2-rc1 java-client jar @@ -149,7 +149,7 @@ io.split.client pluggable-storage - 2.1.0 + 2.1.1-rc1 compile diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index 693016b51..440fa4c77 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,10 +6,10 @@ java-client-parent io.split.client - 4.10.1 + 4.10.2-rc1 - 2.1.0 + 2.1.1-rc1 pluggable-storage jar Package for Pluggable Storage diff --git a/pom.xml b/pom.xml index d3d441c0e..bca37a8c5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.10.1 + 4.10.2-rc1 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index fb354ff47..3aed4269b 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.1 + 4.10.2-rc1 redis-wrapper 3.1.0 @@ -22,7 +22,7 @@ io.split.client pluggable-storage - 2.1.0 + 2.1.1-rc1 compile @@ -35,12 +35,6 @@ junit test - - io.split.client - pluggable-storage - 2.1.0 - compile - diff --git a/testing/pom.xml b/testing/pom.xml index 704c77320..1e2767dbd 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.1 + 4.10.2-rc1 java-client-testing jar From 0de34fe8f189a5c9360eb37038c9600bae74e51a Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 11:01:14 -0300 Subject: [PATCH 4/9] Update versions --- client/pom.xml | 4 ++-- pluggable-storage/pom.xml | 4 ++-- pom.xml | 2 +- redis-wrapper/pom.xml | 4 ++-- testing/pom.xml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 86b70e9c6..c61de5f9f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 java-client jar @@ -149,7 +149,7 @@ io.split.client pluggable-storage - 2.1.1-rc1 + 2.1.0 compile diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index 440fa4c77..32e5198e6 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,10 +6,10 @@ java-client-parent io.split.client - 4.10.2-rc1 + 4.10.2-rc2 - 2.1.1-rc1 + 2.1.0 pluggable-storage jar Package for Pluggable Storage diff --git a/pom.xml b/pom.xml index bca37a8c5..3523fcffe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index 3aed4269b..67e458468 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc1 + 4.10.2-rc2 redis-wrapper 3.1.0 @@ -22,7 +22,7 @@ io.split.client pluggable-storage - 2.1.1-rc1 + 2.1.0 compile diff --git a/testing/pom.xml b/testing/pom.xml index 1e2767dbd..0d39249c6 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 java-client-testing jar From 2e5b919c4eb5c035974494b3d3200a80720d2dd5 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 11:02:28 -0300 Subject: [PATCH 5/9] Update version --- client/pom.xml | 2 +- pluggable-storage/pom.xml | 2 +- pom.xml | 2 +- redis-wrapper/pom.xml | 2 +- testing/pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index c61de5f9f..351d9af27 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2-rc1 java-client jar diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index 32e5198e6..e810cd8f0 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc2 + 4.10.2-rc1 2.1.0 diff --git a/pom.xml b/pom.xml index 3523fcffe..bca37a8c5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2-rc1 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index 67e458468..df266d9cf 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc2 + 4.10.2-rc1 redis-wrapper 3.1.0 diff --git a/testing/pom.xml b/testing/pom.xml index 0d39249c6..1e2767dbd 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2-rc1 java-client-testing jar From bfc354764b15693e9a1738e4c630ef75b2beb648 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 16:14:03 -0300 Subject: [PATCH 6/9] Fix to show log message 'not contain cached feature flag names' for consumer mode --- client/pom.xml | 2 +- .../java/io/split/client/SplitClientImpl.java | 17 +++++++++++++++-- .../io/split/engine/evaluator/EvaluatorImp.java | 2 +- .../split/engine/evaluator/EvaluatorTest.java | 3 ++- pluggable-storage/pom.xml | 2 +- pom.xml | 2 +- redis-wrapper/pom.xml | 2 +- testing/pom.xml | 2 +- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 351d9af27..c61de5f9f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 java-client jar diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index 08e7beaa6..f265f22ee 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -414,8 +414,7 @@ private Map getTreatmentsBySetsWithConfigInternal(String ma List featureFlagNames = new ArrayList<>(); try { checkSDKReady(methodEnum); - featureFlagNames = getAllFlags(cleanFlagSets); - Map result = validateBeforeEvaluate(featureFlagNames, matchingKey, methodEnum,bucketingKey); + Map result = validateBeforeEvaluateByFlagSets(matchingKey, methodEnum,bucketingKey); if(result != null) { return result; } @@ -457,6 +456,20 @@ private Map processEvaluatorResult(Map validateBeforeEvaluateByFlagSets(String matchingKey, MethodEnum methodEnum, + String bucketingKey) { + if (_container.isDestroyed()) { + _log.error(CLIENT_DESTROY); + return new HashMap<>(); + } + if (!KeyValidator.isValid(matchingKey, "matchingKey", _config.maxStringLength(), methodEnum.getMethod())) { + return new HashMap<>(); + } + if (!KeyValidator.bucketingKeyIsValid(bucketingKey, _config.maxStringLength(), methodEnum.getMethod())) { + return new HashMap<>(); + } + return null; + } private Map validateBeforeEvaluate(List featureFlagNames, String matchingKey, MethodEnum methodEnum, String bucketingKey) { if (_container.isDestroyed()) { diff --git a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java index db4da8637..eb56009f9 100644 --- a/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java +++ b/client/src/main/java/io/split/engine/evaluator/EvaluatorImp.java @@ -63,7 +63,7 @@ private List getFeatureFlagNamesByFlagSets(List flagSets) { Map> namesByFlagSets = _splitCacheConsumer.getNamesByFlagSets(flagSets); for (String set: flagSets) { HashSet flags = namesByFlagSets.get(set); - if (flags == null) { + if (flags == null || flags.isEmpty()) { _log.warn(String.format("You passed %s Flag Set that does not contain cached feature flag names, please double check " + "what Flag Sets are in use in the Split user interface.", set)); continue; diff --git a/client/src/test/java/io/split/engine/evaluator/EvaluatorTest.java b/client/src/test/java/io/split/engine/evaluator/EvaluatorTest.java index 272b5aa5b..e6598071b 100644 --- a/client/src/test/java/io/split/engine/evaluator/EvaluatorTest.java +++ b/client/src/test/java/io/split/engine/evaluator/EvaluatorTest.java @@ -153,9 +153,10 @@ public void evaluateWithWhitelistConditionReturnTreatment() { @Test public void evaluateWithSets() { ParsedSplit split = ParsedSplit.createParsedSplitForTests(SPLIT_NAME, 0, false, DEFAULT_TREATMENT_VALUE, _conditions, TRAFFIC_TYPE_VALUE, CHANGE_NUMBER, 2, new HashSet<>(Arrays.asList("set1", "set2"))); - List sets = new ArrayList<>(Arrays.asList("set1")); + List sets = new ArrayList<>(Arrays.asList("set1", "empty_set")); Map> flagSets = new HashMap<>(); flagSets.put("set1", new HashSet<>(Arrays.asList(SPLIT_NAME))); + flagSets.put("empty_set", null); Mockito.when(_splitCacheConsumer.getNamesByFlagSets(sets)).thenReturn(flagSets); Map parsedSplits = new HashMap<>(); parsedSplits.put(SPLIT_NAME, split); diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index e810cd8f0..32e5198e6 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc1 + 4.10.2-rc2 2.1.0 diff --git a/pom.xml b/pom.xml index bca37a8c5..3523fcffe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index df266d9cf..67e458468 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc1 + 4.10.2-rc2 redis-wrapper 3.1.0 diff --git a/testing/pom.xml b/testing/pom.xml index 1e2767dbd..0d39249c6 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc1 + 4.10.2-rc2 java-client-testing jar From 54249703abae056449d7fcb6e33052fdddcbc05a Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 16:46:40 -0300 Subject: [PATCH 7/9] Add some test cases --- client/pom.xml | 2 +- client/src/main/java/io/split/client/SplitClientImpl.java | 7 ++++--- .../java/io/split/storages/memory/InMemoryCacheTest.java | 5 +++++ pluggable-storage/pom.xml | 2 +- pom.xml | 2 +- redis-wrapper/pom.xml | 2 +- testing/pom.xml | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index c61de5f9f..c3882baba 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2 java-client jar diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index f265f22ee..e15410da1 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -48,6 +48,7 @@ public final class SplitClientImpl implements SplitClient { public static final SplitResult SPLIT_RESULT_CONTROL = new SplitResult(Treatments.CONTROL, null); private static final String CLIENT_DESTROY = "Client has already been destroyed - no calls possible"; private static final String CATCHALL_EXCEPTION = "CatchAll Exception"; + private static final String MATCHING_KEY = "matchingKey"; private static final Logger _log = LoggerFactory.getLogger(SplitClientImpl.class); @@ -321,7 +322,7 @@ private SplitResult getTreatmentWithConfigInternal(String matchingKey, String bu return SPLIT_RESULT_CONTROL; } - if (!KeyValidator.isValid(matchingKey, "matchingKey", _config.maxStringLength(), methodEnum.getMethod())) { + if (!KeyValidator.isValid(matchingKey, MATCHING_KEY, _config.maxStringLength(), methodEnum.getMethod())) { return SPLIT_RESULT_CONTROL; } @@ -462,7 +463,7 @@ private Map validateBeforeEvaluateByFlagSets(String matchin _log.error(CLIENT_DESTROY); return new HashMap<>(); } - if (!KeyValidator.isValid(matchingKey, "matchingKey", _config.maxStringLength(), methodEnum.getMethod())) { + if (!KeyValidator.isValid(matchingKey, MATCHING_KEY, _config.maxStringLength(), methodEnum.getMethod())) { return new HashMap<>(); } if (!KeyValidator.bucketingKeyIsValid(bucketingKey, _config.maxStringLength(), methodEnum.getMethod())) { @@ -476,7 +477,7 @@ private Map validateBeforeEvaluate(List featureFlag _log.error(CLIENT_DESTROY); return createMapControl(featureFlagNames); } - if (!KeyValidator.isValid(matchingKey, "matchingKey", _config.maxStringLength(), methodEnum.getMethod())) { + if (!KeyValidator.isValid(matchingKey, MATCHING_KEY, _config.maxStringLength(), methodEnum.getMethod())) { return createMapControl(featureFlagNames); } if (!KeyValidator.bucketingKeyIsValid(bucketingKey, _config.maxStringLength(), methodEnum.getMethod())) { diff --git a/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java b/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java index ada94588f..374f734c9 100644 --- a/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java +++ b/client/src/test/java/io/split/storages/memory/InMemoryCacheTest.java @@ -23,6 +23,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -236,5 +237,9 @@ public void testGetNamesByFlagSets() { _cache.remove("splitName_2"); namesByFlagSets = _cache.getNamesByFlagSets(new ArrayList<>(Arrays.asList("set1", "set2", "set3"))); assertFalse(namesByFlagSets.get("set1").contains("splitName_2")); + _cache.remove("splitName_1"); + namesByFlagSets = _cache.getNamesByFlagSets(new ArrayList<>(Arrays.asList("set1", "set2", "set3"))); + assertFalse(namesByFlagSets.get("set1").contains("splitName_1")); + assertTrue(namesByFlagSets.get("set1").isEmpty()); } } \ No newline at end of file diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index 32e5198e6..6d8a9728e 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc2 + 4.10.2 2.1.0 diff --git a/pom.xml b/pom.xml index 3523fcffe..4cb3c90ce 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index 67e458468..2c089f60f 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.10.2-rc2 + 4.10.2 redis-wrapper 3.1.0 diff --git a/testing/pom.xml b/testing/pom.xml index 0d39249c6..303309ef8 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.10.2-rc2 + 4.10.2 java-client-testing jar From fdf47e7f7a60e8cfa16ae97c1600a4bba17dfd23 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 16:59:27 -0300 Subject: [PATCH 8/9] Remove method not using --- .../main/java/io/split/client/SplitClientImpl.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/client/src/main/java/io/split/client/SplitClientImpl.java b/client/src/main/java/io/split/client/SplitClientImpl.java index e15410da1..e876871e3 100644 --- a/client/src/main/java/io/split/client/SplitClientImpl.java +++ b/client/src/main/java/io/split/client/SplitClientImpl.java @@ -432,7 +432,6 @@ private Map getTreatmentsBySetsWithConfigInternal(String ma return createMapControl(featureFlagNames); } } - private Map processEvaluatorResult(Map evaluatorResult, MethodEnum methodEnum, String matchingKey, String bucketingKey, Map attributes, long initTime){ @@ -471,6 +470,7 @@ private Map validateBeforeEvaluateByFlagSets(String matchin } return null; } + private Map validateBeforeEvaluate(List featureFlagNames, String matchingKey, MethodEnum methodEnum, String bucketingKey) { if (_container.isDestroyed()) { @@ -500,16 +500,6 @@ private Set filterSetsAreInConfig(Set sets, MethodEnum methodEnu } return setsToReturn; } - - private List getAllFlags(Set sets) { - Map> namesBySets = _splitCacheConsumer.getNamesByFlagSets(new ArrayList<>(sets)); - HashSet flags = new HashSet<>(); - for (String set: namesBySets.keySet()) { - flags.addAll(namesBySets.get(set)); - } - return new ArrayList<>(flags); - } - private void recordStats(String matchingKey, String bucketingKey, String featureFlagName, long start, String result, String operation, String label, Long changeNumber, Map attributes) { try { From 2ebec859f3c778614e9ae04b5f5176acd9f42702 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Fri, 1 Dec 2023 17:37:50 -0300 Subject: [PATCH 9/9] Update change logs --- CHANGES.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 490ee8b0e..36b9b2662 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 4.10.2 (Dec 1, 2023) -- Fixed some issues for flag sets. +- Added getTreatmentsByFlagSets without attributes. +- Fixed some issues for flag sets: Not logging a warning when using flag sets that don't contain cached feature flags. 4.10.1 (Nov 9, 2023) - Fixed handler for response http headers.