spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

Jedis implementations of BZPOP* can throw NPE

Open jdeppe-pivotal opened this issue 3 years ago • 1 comments

  • For the Jedis-based implementations of bzpopmin and bzpopmax, a NPE is thrown if the provided timeout elapses and the server responds with a null array.
  • [ ] You have read the Spring Data contribution guidelines.
  • [ ] You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • [ ] You submit test cases (unit or integration tests) that back your changes.
  • [ ] You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

jdeppe-pivotal avatar May 13 '22 19:05 jdeppe-pivotal

This is an example stacktrace:

util.TestException: Encountered exception while performing Redis operations
	at redis.SpringDataRedisClient.doRedisOperations(SpringDataRedisClient.java:144)
	at redis.SpringDataRedisClient.doOps(SpringDataRedisClient.java:123)
	at redis.SpringDataRedisClient.HydraTask_doOps(SpringDataRedisClient.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at hydra.MethExecutor.execute(MethExecutor.java:173)
	at hydra.MethExecutor.execute(MethExecutor.java:141)
	at hydra.TestTask.execute(TestTask.java:197)
	at hydra.RemoteTestModule$1.run(RemoteTestModule.java:222)
Caused by: org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.NullPointerException
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:53)
	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:43)
	at org.springframework.data.redis.connection.jedis.JedisClusterConnection.convertJedisAccessException(JedisClusterConnection.java:784)
	at org.springframework.data.redis.connection.jedis.JedisClusterZSetCommands.convertJedisAccessException(JedisClusterZSetCommands.java:1238)
	at org.springframework.data.redis.connection.jedis.JedisClusterZSetCommands.bZPopMin(JedisClusterZSetCommands.java:407)
	at org.springframework.data.redis.connection.DefaultedRedisConnection.bZPopMin(DefaultedRedisConnection.java:986)
	at org.springframework.data.redis.core.DefaultZSetOperations.lambda$popMin$37(DefaultZSetOperations.java:560)
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:223)
	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
	at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:97)
	at org.springframework.data.redis.core.DefaultZSetOperations.popMin(DefaultZSetOperations.java:560)
	at org.springframework.data.redis.core.ZSetOperations.popMax(ZSetOperations.java:528)
	at redis.SpringDataRedisOperations.bzpopmax(SpringDataRedisOperations.java:416)
	at redis.OperationType.bzpopmax(OperationType.java:478)
	at redis.OperationType.apply(OperationType.java:539)
	at redis.SpringDataRedisClient.doRedisOperations(SpringDataRedisClient.java:137)
	... 10 more
Caused by: java.lang.NullPointerException
	at org.springframework.data.redis.connection.jedis.JedisClusterZSetCommands.toTuple(JedisClusterZSetCommands.java:1259)
	at org.springframework.data.redis.connection.jedis.JedisClusterZSetCommands.bZPopMin(JedisClusterZSetCommands.java:405)
	... 21 more

jdeppe-pivotal avatar May 13 '22 19:05 jdeppe-pivotal

Thank you for your contribution. That's merged, polished, and backported now.

mp911de avatar Sep 16 '22 09:09 mp911de