question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Null pointer exception is thrown when performing action and redis server is down

See original GitHub issue

Expected behavior: Redisson Client should throw checked exception or return bool value when operation on RBucket can not be performed because server is down

Actual behavior When single server will be shut down during application work and some operation on RBucket will be performed, then NullPointer exception exception is thrown. Also redisson treats RBucket object as not null one.

An exception was thrown by org.redisson.misc.RedissonPromise$$Lambda$731/0x0000000840e3b040.operationComplete() java.lang.NullPointerException: null at org.redisson.client.RedisConnection.send(RedisConnection.java:169) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.command.RedisExecutor.sendCommand(RedisExecutor.java:622) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.command.RedisExecutor.lambda$execute$2(RedisExecutor.java:151) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.misc.RedissonPromise.lambda$onComplete$0(RedissonPromise.java:187) ~[redisson-3.15.0.jar:3.15.0] at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:184) ~[netty-common-4.1.58.Final.jar:4.1.58.Final] at org.redisson.misc.RedissonPromise.onComplete(RedissonPromise.java:181) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.command.RedisExecutor.execute(RedisExecutor.java:139) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.command.CommandAsyncService.async(CommandAsyncService.java:606) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.command.CommandAsyncService.writeAsync(CommandAsyncService.java:591) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.RedissonObject.deleteAsync(RedissonObject.java:202) ~[redisson-3.15.0.jar:3.15.0] at org.redisson.RedissonObject.delete(RedissonObject.java:197) ~[redisson-3.15.0.jar:3.15.0]

Steps to reproduce or test case

  1. Turn on redis and redisson with single server mode
  2. Save some value by using RBucket
  3. Shut down redis server
  4. Try to save / remove another value by using RedissonClient (by using RBucket)

Redis version 6.2.0

Redisson version 3.15.0

Redisson configuration

  • single server
  • REDIS_MIN_CONNECTION_POOL_SIZE: 24
  • REDIS_MAX_CONNECTION_POOL_SIZE: 64
  • REDIS_IDLE_CONNECTION_TIMEOUT=300000
  • REDIS_RETRY_ATTEMPTS=0
  • REDIS_TIMEOUT=500
  • REDIS_CONNECT_TIMEOUT=1000

Setting pingConnectionInterval does not do the work. I think that send method from RedisConnection class is culprit, it does not check whether channel has null value.

    public <T, R> ChannelFuture send(CommandData<T, R> data) {
        return channel.writeAndFlush(data);
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gietkicommented, Apr 21, 2021

Yeah, I came across identical scenario today. Why o why do you throw NPE?

0reactions
mrnikocommented, Apr 26, 2021

I didn’t change netty version since 3.15.4 version. Please note it’s not all in single jar package. It doesn’t contain dependencies as redisson-all jar

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis client throw null exception on get · Issue #11351 - GitHub
Getting null pointer exception when key not exists with following code: @Path("/testing") class TestController { @Inject lateinit var ...
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
NullPointerException is being thrown in statement int i = t.x; ... as “HTTP Status 500 – Internal Server Error” and root cause as...
Read more >
Why is redis throwing NullPointerException running via JUnit ...
1 Answer 1 ... The problem is that both the redisTemplate and the jedisConnectionFactory need to have afterPropertiesSet() called. Usually this is ...
Read more >
How to Fix and Avoid NullPointerException in Java - Rollbar
The NullPointerException occurs due to a situation in application code where an uninitialized object is attempted to be accessed or modified.
Read more >
How to Handle NullPointerException in Java - freeCodeCamp
The reason you are getting this error is because we are trying to perform the length() operation on str1 which is null ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found