Skip to content

Fix potential NullPointerException when using Jedis Cluster BZPOP* #2324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jdeppe-pivotal
Copy link
Contributor

  • 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).

- 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.
@jdeppe-pivotal
Copy link
Contributor Author

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 13, 2022
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 16, 2022
@mp911de mp911de changed the title Jedis implementations of BZPOP* can throw NPE Fix potential NullPointerException when using Jedis Cluster BZPOP* Sep 16, 2022
@mp911de mp911de closed this in c8f4d0c Sep 16, 2022
mp911de added a commit that referenced this pull request Sep 16, 2022
Add author tags. Align Lettuce BZPOPMIN/MAX tests. Increase timeout to 10ms as Redis blocks indefinitely if the timeout is less than 0.01.

See #2324
mp911de pushed a commit that referenced this pull request Sep 16, 2022
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.

Closes #2324
mp911de added a commit that referenced this pull request Sep 16, 2022
Add author tags. Align Lettuce BZPOPMIN/MAX tests. Increase timeout to 10ms as Redis blocks indefinitely if the timeout is less than 0.01.

See #2324
mp911de pushed a commit that referenced this pull request Sep 16, 2022
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.

Closes #2324
mp911de added a commit that referenced this pull request Sep 16, 2022
Add author tags. Align Lettuce BZPOPMIN/MAX tests. Increase timeout to 10ms as Redis blocks indefinitely if the timeout is less than 0.01.

See #2324
@mp911de
Copy link
Member

mp911de commented Sep 16, 2022

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

@mp911de mp911de added this to the 2.6.7 (2021.1.7) milestone Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants