diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommands.java index 9deaa0a74..912ffb94e 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveHashCommands.java @@ -222,7 +222,7 @@ class LettuceReactiveHashCommands implements ReactiveHashCommands { @Override public Flux> hStrLen(Publisher commands) { - return connection.execute(cmd -> Flux.from(commands).flatMap(command -> { + return connection.execute(cmd -> Flux.from(commands).concatMap(command -> { Assert.notNull(command.getKey(), "Key must not be null!"); Assert.notNull(command.getField(), "Field must not be null!"); diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceTestClientConfiguration.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceTestClientConfiguration.java index dd5ff8de3..e71bb5b40 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceTestClientConfiguration.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettuceTestClientConfiguration.java @@ -23,7 +23,7 @@ import org.springframework.data.redis.connection.lettuce.LettuceClientConfigurat /** * Creates a specific client configuration for Lettuce tests. - * + * * @author Mark Paluch */ public class LettuceTestClientConfiguration { diff --git a/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java b/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java index d784b2f75..c647c1a76 100644 --- a/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java +++ b/src/test/java/org/springframework/data/redis/core/script/DefaultReactiveScriptExecutorTests.java @@ -24,8 +24,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.junit.After; import org.junit.AfterClass; -import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.core.io.ClassPathResource; @@ -35,6 +35,7 @@ import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.connection.lettuce.LettuceTestClientConfiguration; +import org.springframework.data.redis.core.RedisCallback; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.serializer.GenericToStringSerializer; @@ -48,6 +49,7 @@ import org.springframework.scripting.support.StaticScriptSource; /** * @author Mark Paluch + * @author Christoph Strobl */ public class DefaultReactiveScriptExecutorTests { @@ -74,12 +76,16 @@ public class DefaultReactiveScriptExecutorTests { } } - @Before - public void before() { + @After + public void tearDown() { RedisConnection connection = connectionFactory.getConnection(); - connection.flushDb(); - connection.close(); + try { + connection.scriptingCommands().scriptFlush(); + connection.flushDb(); + } finally { + connection.close(); + } } protected RedisConnectionFactory getConnectionFactory() { @@ -217,15 +223,25 @@ public class DefaultReactiveScriptExecutorTests { } @Test // DATAREDIS-711 - public void testExecuteCachedNullKeys() { + public void executeAddsScriptToScriptCache() { DefaultRedisScript script = new DefaultRedisScript<>(); script.setScriptText("return 'HELLO'"); script.setResultType(String.class); // Execute script twice, second time should be from cache + + assertThat(stringTemplate.execute( + (RedisCallback>) connection -> connection.scriptingCommands().scriptExists(script.getSha1()))) + .containsExactly(false); + StepVerifier.create(stringScriptExecutor.execute(script, Collections.emptyList())).expectNext("HELLO") .verifyComplete(); + + assertThat(stringTemplate.execute( + (RedisCallback>) connection -> connection.scriptingCommands().scriptExists(script.getSha1()))) + .containsExactly(true); + StepVerifier.create(stringScriptExecutor.execute(script, Collections.emptyList())).expectNext("HELLO") .verifyComplete(); }