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:
@@ -283,7 +283,8 @@ public interface ReactiveHashCommands {
|
||||
* @see <a href="https://redis.io/commands/hget">Redis Documentation: HGET</a>
|
||||
*/
|
||||
default Mono<ByteBuffer> hGet(ByteBuffer key, ByteBuffer field) {
|
||||
return hMGet(key, Collections.singletonList(field)).flatMapIterable(Function.identity()).next();
|
||||
return hMGet(key, Collections.singletonList(field)).filter(it -> !it.contains(null))
|
||||
.flatMapIterable(Function.identity()).next();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -107,7 +107,7 @@ class LettuceReactiveHashCommands implements ReactiveHashCommands {
|
||||
if (command.getFields().size() == 1) {
|
||||
ByteBuffer key = command.getFields().iterator().next();
|
||||
result = cmd.hget(command.getKey(), key.duplicate()).map(value -> KeyValue.fromNullable(key, value))
|
||||
.map(Collections::singletonList).onErrorReturn(Collections.emptyList());
|
||||
.defaultIfEmpty(KeyValue.empty(key)).map(Collections::singletonList);
|
||||
} else {
|
||||
result = cmd.hmget(command.getKey(), command.getFields().stream().toArray(ByteBuffer[]::new)).collectList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user