Return null elements for absent keys using reactive MGET.

We now use correctly null to indicate absent keys when using reactive MGET. Previously, we used an empty byte buffer that could be incorrectly translated to an empty string when using the string codec. An empty byte buffer can also be returned if the value length is zero leading to a state that doesn't allow distinguishing between absence and empty value.

Closes #2402
This commit is contained in:
Mark Paluch
2022-09-13 15:11:41 +02:00
parent 359d917a9e
commit 3576bbfa8c
3 changed files with 9 additions and 15 deletions

View File

@@ -202,7 +202,7 @@ public class LettuceReactiveStringCommandsIntegrationTests extends LettuceReacti
Mono<List<ByteBuffer>> result = connection.stringCommands()
.mGet(Arrays.asList(KEY_1_BBUFFER, KEY_2_BBUFFER, KEY_3_BBUFFER));
assertThat(result.block()).containsExactly(VALUE_1_BBUFFER, ByteBuffer.allocate(0), VALUE_3_BBUFFER);
assertThat(result.block()).containsExactly(VALUE_1_BBUFFER, null, VALUE_3_BBUFFER);
}
@ParameterizedRedisTest // DATAREDIS-525

View File

@@ -306,13 +306,6 @@ public class DefaultReactiveValueOperationsIntegrationTests<K, V> {
V value2 = valueFactory.instance();
V absentValue = null;
if (serializer instanceof StringRedisSerializer) {
absentValue = (V) "";
}
if (value1 instanceof ByteBuffer) {
absentValue = (V) ByteBuffer.wrap(new byte[0]);
}
Map<K, V> map = new LinkedHashMap<>();
map.put(key1, value1);
map.put(key2, value2);