Skip to content

Commit 29ddd1a

Browse files
authored
Fix issue with array initialization (#3123)
1 parent a8613e8 commit 29ddd1a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/io/lettuce/core/output/KeyValueListOutput.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void set(ByteBuffer bytes) {
7474
public void multi(int count) {
7575

7676
if (!initialized) {
77-
output = OutputFactory.newList(keys == null ? count / 2 : count);
77+
output = OutputFactory.newList(count);
7878
initialized = true;
7979
}
8080
}

src/test/java/io/lettuce/core/commands/HashCommandIntegrationTests.java

+14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import javax.inject.Inject;
4242
import java.time.Duration;
4343
import java.time.Instant;
44+
import java.util.Collection;
4445
import java.util.Collections;
4546
import java.util.Date;
4647
import java.util.HashSet;
@@ -265,6 +266,19 @@ void hrandfield() {
265266
KeyValue.fromNullable("two", "2"), KeyValue.fromNullable("three", "3"));
266267
}
267268

269+
@Test
270+
@EnabledOnCommand("HRANDFIELD")
271+
void hrandfieldIssue3122() {
272+
273+
Map<String, String> hash = new LinkedHashMap<>();
274+
hash.put("one", "1");
275+
hash.put("two", "2");
276+
277+
redis.hset(key, hash);
278+
assertThat(redis.hrandfieldWithvalues(key)).isIn(KeyValue.fromNullable("one", "1"), KeyValue.fromNullable("two", "2"),
279+
KeyValue.fromNullable("three", "3"));
280+
}
281+
268282
@Test
269283
void hset() {
270284
assertThat(redis.hset(key, "one", "1")).isTrue();

0 commit comments

Comments
 (0)