diff --git a/src/main/java/io/lettuce/core/output/KeyValueListOutput.java b/src/main/java/io/lettuce/core/output/KeyValueListOutput.java index 686bbdddf..3becfe80d 100644 --- a/src/main/java/io/lettuce/core/output/KeyValueListOutput.java +++ b/src/main/java/io/lettuce/core/output/KeyValueListOutput.java @@ -74,7 +74,7 @@ public void set(ByteBuffer bytes) { public void multi(int count) { if (!initialized) { - output = OutputFactory.newList(keys == null ? count / 2 : count); + output = OutputFactory.newList(count); initialized = true; } } diff --git a/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java index 70a2a263e..45ee95eb8 100644 --- a/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java @@ -41,6 +41,7 @@ import javax.inject.Inject; import java.time.Duration; import java.time.Instant; +import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; @@ -265,6 +266,19 @@ void hrandfield() { KeyValue.fromNullable("two", "2"), KeyValue.fromNullable("three", "3")); } + @Test + @EnabledOnCommand("HRANDFIELD") + void hrandfieldIssue3122() { + + Map hash = new LinkedHashMap<>(); + hash.put("one", "1"); + hash.put("two", "2"); + + redis.hset(key, hash); + assertThat(redis.hrandfieldWithvalues(key)).isIn(KeyValue.fromNullable("one", "1"), KeyValue.fromNullable("two", "2"), + KeyValue.fromNullable("three", "3")); + } + @Test void hset() { assertThat(redis.hset(key, "one", "1")).isTrue();