Skip to content

Commit 9442f71

Browse files
fliskychristophstrobl
authored andcommitted
DATAREDIS-824 - Fix potential NPE in DefaultReactiveHashOperations when deserializing values.
Avoid ByteBuffer creation for null values indicating absent keys in hash. Original Pull Request: #340
1 parent 7778fbf commit 9442f71

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private List<HV> deserializeHashValues(List<ByteBuffer> source) {
277277

278278
List<HV> values = new ArrayList<>(source.size());
279279
for (ByteBuffer byteBuffer : source) {
280-
values.add(readHashValue(byteBuffer));
280+
values.add(byteBuffer == null ? null : readHashValue(byteBuffer));
281281
}
282282
return values;
283283
}

src/test/java/org/springframework/data/redis/core/DefaultReactiveHashOperationsIntegrationTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ public void multiGet() {
178178
HK hashkey2 = hashKeyFactory.instance();
179179
HV hashvalue2 = hashValueFactory.instance();
180180

181+
StepVerifier.create(hashOperations.multiGet(key, Arrays.asList(hashkey1, hashkey2))) //
182+
.consumeNextWith(actual -> {
183+
assertThat(actual).hasSize(2).containsSequence(null, null);
184+
}) //
185+
.verifyComplete();
186+
181187
putAll(key, hashkey1, hashvalue1, hashkey2, hashvalue2);
182188

183189
StepVerifier.create(hashOperations.multiGet(key, Arrays.asList(hashkey1, hashkey2))) //

0 commit comments

Comments
 (0)