Skip to content

Commit

Permalink
Fix issue with array initialization (#3123)
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun authored Jan 11, 2025
1 parent a8613e8 commit 29ddd1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -265,6 +266,19 @@ void hrandfield() {
KeyValue.fromNullable("two", "2"), KeyValue.fromNullable("three", "3"));
}

@Test
@EnabledOnCommand("HRANDFIELD")
void hrandfieldIssue3122() {

Map<String, String> 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();
Expand Down

0 comments on commit 29ddd1a

Please sign in to comment.