[DATAREDIS-852] NullPointerException using Lettuce with Range.Bound.unbounded() Created: 19/Jul/18  Updated: 26/Jul/18  Resolved: 24/Jul/18

Status: Closed
Project: Spring Data Redis
Component/s: Lettuce Driver
Affects Version/s: 2.0.8 (Kay SR8)
Fix Version/s: 2.1 RC1 (Lovelace), 2.0.9 (Kay SR9)

Type: Bug Priority: Major
Reporter: Michele Assignee: Mark Paluch
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Last updater: Mark Paluch
Pull Request URL: https://github.com/spring-projects/spring-data-redis/pull/353
Sprint: Lovelace RC1

 Description   

The implementation of LettuceReactiveZSetCommands#zRange and LettuceReactiveZSetCommands.ArgumentConverters#rangeToBoundArgumentConverter break when the Range provided has a bound unbounded().

In the case of LettuceReactiveZSetCommands#zRange (and others), it is an unboxing issue. Since the code is using, e.g., command.getRange().getLowerBound().getValue().orElse(null) and the result is passed into RedisSortedSetReactiveCommands.zrange, which wants primitive longs, NPEs are thrown due to the unboxing:

java.lang.NullPointerException: null at org.springframework.data.redis.connection.lettuce.LettuceReactiveZSetCommands.lambda$null$20(LettuceReactiveZSetCommands.java:196) ...

The same bug likely occurs in a bunch of other places related with ranges (same code style, did not repro yet), namely:

  • org.springframework.data.redis.connection.lettuce.LettuceReactiveListCommands#lRange
  • * org.springframework.data.redis.connection.lettuce.LettuceReactiveListCommands#lTrim
  • * org.springframework.data.redis.connection.lettuce.LettuceReactiveStringCommands#getRange

In the case of LettuceReactiveZSetCommands.ArgumentConverters#rangeToBoundArgumentConverter, the issue is that the code simply cannot cope with an unbounded range, and instead of returning Boundary.unbounded(), throws another NPE.



 Comments   
Comment by Michele [ 19/Jul/18 ]

I have a commit to fix this, I want to polish it a tad and then I will open a PR in the next few days.

Comment by Mark Paluch [ 19/Jul/18 ]

Good catch. Happy to review your pull request.

Generated at Sat Jan 25 17:57:23 UTC 2020 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.