DATAREDIS-779 - Emit false if a conditional ReactiveStringCommands.set(…) does not set a value.

We now emit false when SET XX/SET NX complete without setting the value because the condition was evaluated to not set the value. Previously, we did not emit a value as Redis responds null (nil). This behavior becomes visible through ReactiveValueOperations.set[ifPresent|ifAbsent](…) methods.

This is a breaking change in the sense that changes the character of ReactiveValueOperations.set[ifPresent|ifAbsent](…) from an optionally emitted element to always emit. Reactive sequences that currently resume operation with .switchIfEmpty(…) will no longer utilize the fallback publisher.

Original pull request: #317.
This commit is contained in:
Jiahe Cai (佳何 蔡)
2018-03-06 14:08:04 +08:00
committed by Mark Paluch
parent 1f6790b100
commit fe80804873
2 changed files with 7 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
*
* @author Mark Paluch
* @author Christoph Strobl
* @author Jiahe Cai
*/
@RunWith(Parameterized.class)
@SuppressWarnings("unchecked")
@@ -131,7 +132,7 @@ public class DefaultReactiveValueOperationsIntegrationTests<K, V> {
StepVerifier.create(valueOperations.setIfAbsent(key, value)).expectNext(true).verifyComplete();
StepVerifier.create(valueOperations.setIfAbsent(key, value)).verifyComplete();
StepVerifier.create(valueOperations.setIfAbsent(key, value)).expectNext(false).verifyComplete();
}
@Test // DATAREDIS-602
@@ -141,7 +142,7 @@ public class DefaultReactiveValueOperationsIntegrationTests<K, V> {
V value = valueFactory.instance();
V laterValue = valueFactory.instance();
StepVerifier.create(valueOperations.setIfPresent(key, value)).verifyComplete();
StepVerifier.create(valueOperations.setIfPresent(key, value)).expectNext(false).verifyComplete();
StepVerifier.create(valueOperations.set(key, value)).expectNext(true).verifyComplete();