diff --git a/client/pom.xml b/client/pom.xml
index 93bb93ee4..198f80a3d 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -5,9 +5,9 @@
io.split.client
java-client-parent
- 4.18.1
+ 4.18.2
- 4.18.1
+ 4.18.2
java-client
jar
Java Client
diff --git a/client/src/test/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumerTest.java b/client/src/test/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumerTest.java
index d12badc0c..befe96452 100644
--- a/client/src/test/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumerTest.java
+++ b/client/src/test/java/io/split/storages/pluggable/adapters/UserCustomSplitAdapterConsumerTest.java
@@ -120,6 +120,34 @@ public void testGetAll() {
Mockito.verify(_userStorageWrapper, Mockito.times(1)).getMany(Mockito.anyObject());
}
+ @Test
+ public void testGetSplitNames() {
+ Split split = getSplit(SPLIT_NAME);
+ Split split2 = getSplit(SPLIT_NAME+"2");
+ List listResultExpected = Stream.of(split, split2).collect(Collectors.toList());
+ Set keysResult = Stream.of(SPLIT_NAME, SPLIT_NAME+"2").collect(Collectors.toSet());
+ Mockito.when(_userStorageWrapper.getKeysByPrefix(Mockito.anyObject())).
+ thenReturn(keysResult);
+ List splitsResult = _userCustomSplitAdapterConsumer.splitNames();
+ Assert.assertNotNull(splitsResult);
+ Assert.assertEquals(listResultExpected.size(), splitsResult.size());
+ Assert.assertEquals(SPLIT_NAME, splitsResult.get(1));
+ Assert.assertEquals(SPLIT_NAME+"2", splitsResult.get(0));
+ Mockito.verify(_userStorageWrapper, Mockito.times(1)).getKeysByPrefix(Mockito.anyString());
+
+ // default prefix
+ listResultExpected = Stream.of(split, split2).collect(Collectors.toList());
+ keysResult = Stream.of("SPLITIO.split." + SPLIT_NAME, "SPLITIO.split." + SPLIT_NAME+"2").collect(Collectors.toSet());
+ Mockito.when(_userStorageWrapper.getKeysByPrefix(Mockito.anyObject())).
+ thenReturn(keysResult);
+
+ splitsResult = _userCustomSplitAdapterConsumer.splitNames();
+ Assert.assertNotNull(splitsResult);
+ Assert.assertEquals(listResultExpected.size(), splitsResult.size());
+ Assert.assertEquals(SPLIT_NAME, splitsResult.get(1));
+ Assert.assertEquals(SPLIT_NAME+"2", splitsResult.get(0));
+ }
+
@Test
public void testGetAllWithWrapperFailing() {
Mockito.when(_userStorageWrapper.get(PrefixAdapter.buildGetAllSplit())).
diff --git a/okhttp-modules/pom.xml b/okhttp-modules/pom.xml
index 2971f627d..3753050e0 100644
--- a/okhttp-modules/pom.xml
+++ b/okhttp-modules/pom.xml
@@ -5,10 +5,10 @@
java-client-parent
io.split.client
- 4.18.1
+ 4.18.2
4.0.0
- 4.18.1
+ 4.18.2
okhttp-modules
jar
http-modules
diff --git a/pluggable-storage/pom.xml b/pluggable-storage/pom.xml
index 0b67454d6..c6d3abb70 100644
--- a/pluggable-storage/pom.xml
+++ b/pluggable-storage/pom.xml
@@ -6,7 +6,7 @@
java-client-parent
io.split.client
- 4.18.1
+ 4.18.2
2.1.0
diff --git a/pom.xml b/pom.xml
index 58fa66801..d0d321ed7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
io.split.client
java-client-parent
- 4.18.1
+ 4.18.2
diff --git a/redis-wrapper/pom.xml b/redis-wrapper/pom.xml
index 0794a708d..486d5dc8f 100644
--- a/redis-wrapper/pom.xml
+++ b/redis-wrapper/pom.xml
@@ -6,10 +6,10 @@
java-client-parent
io.split.client
- 4.18.1
+ 4.18.2
redis-wrapper
- 3.1.1
+ 3.1.2
jar
Package for Redis Wrapper Implementation
Implements Redis Pluggable Storage
diff --git a/redis-wrapper/src/main/java/redis/RedisSingle.java b/redis-wrapper/src/main/java/redis/RedisSingle.java
index f55da2b4b..97fdbbf98 100644
--- a/redis-wrapper/src/main/java/redis/RedisSingle.java
+++ b/redis-wrapper/src/main/java/redis/RedisSingle.java
@@ -95,7 +95,9 @@ public String getAndSet(String key, String item) throws Exception {
public Set getKeysByPrefix(String prefix) throws Exception {
try (Jedis jedis = this.jedisPool.getResource()) {
Set keysWithPrefix = jedis.keys(_commonRedis.buildKeyWithPrefix(prefix));
- keysWithPrefix = keysWithPrefix.stream().map(key -> key.replace(_commonRedis.getPrefix() + ".", "")).collect(Collectors.toSet());
+ if (!_commonRedis.getPrefix().isEmpty()) {
+ keysWithPrefix = keysWithPrefix.stream().map(key -> key.replace(_commonRedis.getPrefix() + ".", "")).collect(Collectors.toSet());
+ }
return keysWithPrefix;
} catch (Exception ex) {
throw new RedisException(ex.getMessage());
diff --git a/redis-wrapper/src/test/java/redis/RedisSingleTest.java b/redis-wrapper/src/test/java/redis/RedisSingleTest.java
index 9b7e0c4de..8f70c3240 100644
--- a/redis-wrapper/src/test/java/redis/RedisSingleTest.java
+++ b/redis-wrapper/src/test/java/redis/RedisSingleTest.java
@@ -104,6 +104,30 @@ public void testGetKeysByPrefix() throws Exception {
}
}
+ @Test
+ public void testGetKeysByPrefixWithoutCustomPrefix() throws Exception {
+ Map map = new HashMap<>();
+ map.put("SPLITIO.item-1", "1");
+ map.put("SPLITIO.item-2", "2");
+ map.put("SPLITIO.item-3", "3");
+ map.put("SPLITIO.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("SPLITIO.item*");
+
+ Assert.assertEquals(3, result.size());
+ Assert.assertTrue(result.contains("SPLITIO.item-1"));
+ Assert.assertTrue(result.contains("SPLITIO.item-2"));
+ Assert.assertTrue(result.contains("SPLITIO.item-3"));
+ } finally {
+ storageWrapper.delete(new ArrayList<>(map.keySet()));
+ }
+ }
+
@Test
public void testIncrementAndDecrement() throws Exception {
Map map = new HashMap<>();
diff --git a/testing/pom.xml b/testing/pom.xml
index 6439f6169..d101f697b 100644
--- a/testing/pom.xml
+++ b/testing/pom.xml
@@ -5,11 +5,11 @@
io.split.client
java-client-parent
- 4.18.1
+ 4.18.2
java-client-testing
jar
- 4.18.1
+ 4.18.2
Java Client For Testing
Testing suite for Java SDK for Split