diff --git a/CHANGES.txt b/CHANGES.txt index ee78d8ba1..f920ad693 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +4.8.1 (Aug 1, 2023) +- Added the checkstyle linter. +- Fixed the use case when the prefix is empty for Redis. + 4.8.0 (Jul 18, 2023) - Improved streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system. - Updated `com.google.guava` dependence to 32.0.1 for fixing a vulnerability. diff --git a/client/pom.xml b/client/pom.xml index 4c1afd402..a775f5fb4 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.8.0 + 4.8.1 java-client jar diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml index 240e626f5..f2a69fc6a 100644 --- a/pluggable-storage/pom.xml +++ b/pluggable-storage/pom.xml @@ -6,7 +6,7 @@ java-client-parent io.split.client - 4.8.0 + 4.8.1 2.0.0 diff --git a/pom.xml b/pom.xml index dd0b5614e..9b4160086 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.split.client java-client-parent - 4.8.0 + 4.8.1 diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml index 2e6c6da58..99b77073e 100644 --- a/redis-wrapper/pom.xml +++ b/redis-wrapper/pom.xml @@ -6,10 +6,10 @@ java-client-parent io.split.client - 4.8.0 + 4.8.1 redis-wrapper - 3.0.0 + 3.0.1 jar Package for Redis Wrapper Implementation Implements Redis Pluggable Storage diff --git a/redis-wrapper/src/main/java/redis/common/CommonRedis.java b/redis-wrapper/src/main/java/redis/common/CommonRedis.java index 907c73e8c..895205b96 100644 --- a/redis-wrapper/src/main/java/redis/common/CommonRedis.java +++ b/redis-wrapper/src/main/java/redis/common/CommonRedis.java @@ -17,6 +17,9 @@ public static CommonRedis create(String prefix) { } public String buildKeyWithPrefix(String key) { + if (_prefix.isEmpty()) { + return key; + } return String.format("%s.%s", _prefix, key); } diff --git a/redis-wrapper/src/test/java/redis/RedisSingleTest.java b/redis-wrapper/src/test/java/redis/RedisSingleTest.java index 286c49af2..a58e0673a 100644 --- a/redis-wrapper/src/test/java/redis/RedisSingleTest.java +++ b/redis-wrapper/src/test/java/redis/RedisSingleTest.java @@ -4,7 +4,6 @@ import org.junit.Test; import pluggable.CustomStorageWrapper; import redis.clients.jedis.JedisPool; -import redis.common.CommonRedis; import java.util.ArrayList; import java.util.Arrays; @@ -16,7 +15,6 @@ import java.util.stream.Stream; public class RedisSingleTest { - private final CommonRedis _commonRedis = CommonRedis.create("test-prefix:"); @Test public void testSetAndGet() throws Exception { @@ -255,5 +253,29 @@ public void testDisconnect() throws Exception { RedisSingle storageWrapper = new RedisSingle(new JedisPool(), "test-prefix"); Assert.assertTrue(storageWrapper.disconnect()); } -} + @Test + public void testWithoutPrefix() throws Exception { + Map map = new HashMap<>(); + map.put("item-1", "1"); + map.put("item-2", "2"); + map.put("item-3", "3"); + map.put("i-4", "4"); + RedisSingle storageWrapper = new RedisSingle(new JedisPool(), ""); + try { + for (Map.Entry entry : map.entrySet()) { + storageWrapper.set(entry.getKey(), entry.getValue()); + } + + Set result = storageWrapper.getKeysByPrefix("item*"); + + Assert.assertEquals(3, result.size()); + Assert.assertTrue(result.contains("item-1")); + Assert.assertTrue(result.contains("item-2")); + Assert.assertTrue(result.contains("item-3")); + } + finally { + storageWrapper.delete(new ArrayList<>(map.keySet())); + } + } +} \ No newline at end of file diff --git a/redis-wrapper/src/test/java/redis/common/CommonRedisTest.java b/redis-wrapper/src/test/java/redis/common/CommonRedisTest.java new file mode 100644 index 000000000..4b36b0e97 --- /dev/null +++ b/redis-wrapper/src/test/java/redis/common/CommonRedisTest.java @@ -0,0 +1,17 @@ +package redis.common; + +import org.junit.Assert; +import org.junit.Test; + + +public class CommonRedisTest { + + @Test + public void testBuildKey(){ + CommonRedis commonRedisWithPrefix = CommonRedis.create("testing:"); + Assert.assertEquals("testing:.feature_flag1", commonRedisWithPrefix.buildKeyWithPrefix("feature_flag1")); + + CommonRedis commonRedisWithoutPrefix = CommonRedis.create(""); + Assert.assertEquals("feature_flag2", commonRedisWithoutPrefix.buildKeyWithPrefix("feature_flag2")); + } +} \ No newline at end of file diff --git a/testing/pom.xml b/testing/pom.xml index b75f26bd4..d35996d06 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -5,7 +5,7 @@ io.split.client java-client-parent - 4.8.0 + 4.8.1 java-client-testing jar