spring-projects / spring-data-redis

Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-redis/
Apache License 2.0
1.77k stars 1.17k forks source link

NPE when command timeout and MultiValueResponse.output is null [DATAREDIS-1081] #1653

Open spring-projects-issues opened 4 years ago

spring-projects-issues commented 4 years ago

zhou-hao opened DATAREDIS-1081 and commented

https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java#L296-L302https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java#L296-L302

io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 minute(s) at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Assembly trace from producer [reactor.core.publisher.MonoFromPublisher] : reactor.core.publisher.Mono.from(Mono.java:362) io.lettuce.core.AbstractRedisReactiveCommands.createMono(AbstractRedisReactiveCommands.java:433)Error has been observed at the following site(s): |_ Mono.from ⇢ at io.lettuce.core.AbstractRedisReactiveCommands.createMono(AbstractRedisReactiveCommands.java:433)Stack trace: at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51) at io.lettuce.core.protocol.CommandExpiryWriter.lambda$potentiallyExpire$0(CommandExpiryWriter.java:167) at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38) at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:139) at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

java.lang.NullPointerException: The mapper returned a null value. at java.util.Objects.requireNonNull(Objects.java:228) Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Assembly trace from producer [reactor.core.publisher.MonoMapFuseable] : reactor.core.publisher.Mono.map(Mono.java:3021) org.springframework.data.redis.connection.ReactiveHashCommands.hGet(ReactiveHashCommands.java:285)Error has been observed at the following site(s): |           Mono.map ⇢ at org.springframework.data.redis.connection.ReactiveHashCommands.hGet(ReactiveHashCommands.java:285) |           Mono.map ⇢ at org.springframework.data.redis.core.DefaultReactiveHashOperations.lambda$get$4(DefaultReactiveHashOperations.java:93) |     Flux.usingWhen ⇢ at org.springframework.data.redis.core.ReactiveRedisTemplate.doInConnection(ReactiveRedisTemplate.java:196) |          Mono.from ⇢ at org.springframework.data.redis.core.ReactiveRedisTemplate.createMono(ReactiveRedisTemplate.java:180)


Referenced from: pull request https://github.com/spring-projects/spring-data-redis/pull/516/files

spring-projects-issues commented 4 years ago

Christoph Strobl commented

Hi, Can you please provide a bit more information as we've not been able to reproduce the issue on current master. Everything looks good there from our perspective.

Which version of spring-data-redis are you using? What does your setup look like? Do you have a reproduceable example?

spring-projects-issues commented 4 years ago

Mark Paluch commented

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue

spring-projects-issues commented 4 years ago

zhou-hao commented

spring-data-redis:2.2.5-RELEASE

redis: 5.0.4

reproduceable example: 

public static void main(String[] args) {     LettuceClientConfiguration clientConfiguration= LettuceClientConfiguration.builder()        .commandTimeout(Duration.ofMillis(1)) //mock timeout        .build();

       LettuceConnectionFactory factory = new LettuceConnectionFactory(new RedisStandaloneConfiguration("localhost", 6379),clientConfiguration);

      factory.afterPropertiesSet();       operations = new ReactiveRedisTemplate<>(factory, RedisSerializationContext.java());

getRedisTemplate()      .opsForHash()      .get("test","test")      .as(StepVerifier::create)      .expectComplete()      .verify(); }