Return single-element list with empty value when ReactiveHashOperations.hMGet(…) for a single key returns no value.

We now return a list containing a single empty KeyValue element when ReactiveHashOperations.hMGet(…) called for a single key returns no value.

Previously, the code used onErrorReturn(…) which returned the wrong value and suppressed errors.

Closes #2210
This commit is contained in:
Mark Paluch
2021-12-10 09:54:19 +01:00
parent bae2eae4f9
commit 9a56c38e2c
3 changed files with 12 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ import reactor.test.StepVerifier;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -110,12 +111,19 @@ public class LettuceReactiveHashCommandsIntegrationTests extends LettuceReactive
}).verifyComplete();
}
@ParameterizedRedisTest // DATAREDIS-525
@ParameterizedRedisTest // DATAREDIS-525, GH-2210
void hMGetShouldReturnNullValueForFieldsThatHaveNoValue() {
nativeCommands.hset(KEY_1, FIELD_1, VALUE_1);
nativeCommands.hset(KEY_1, FIELD_3, VALUE_3);
connection.hashCommands().hMGet(KEY_1_BBUFFER, Collections.singletonList(FIELD_1_BBUFFER)).as(StepVerifier::create)
.expectNext(Collections.singletonList(VALUE_1_BBUFFER)).verifyComplete();
connection.hashCommands().hMGet(KEY_1_BBUFFER, Collections.singletonList(FIELD_2_BBUFFER))
.as(StepVerifier::create)
.expectNext(Collections.singletonList(null)).verifyComplete();
connection.hashCommands().hMGet(KEY_1_BBUFFER, Arrays.asList(FIELD_1_BBUFFER, FIELD_2_BBUFFER, FIELD_3_BBUFFER))
.as(StepVerifier::create)
.expectNext(Arrays.asList(VALUE_1_BBUFFER, null, VALUE_3_BBUFFER)).verifyComplete();