jedis icon indicating copy to clipboard operation
jedis copied to clipboard

Question: NullPointerException

Open mouadelfakir opened this issue 3 years ago • 3 comments

My log is full of NullPointerException

Expected behavior

No NullPointerException

Actual behavior

INFO   | jvm 1    | main    | 2020/07/10 16:47:59.218 | 
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at redis.clients.jedis.BinaryJedis.getDB(BinaryJedis.java:3343)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at redis.clients.jedis.JedisFactory.activateObject(JedisFactory.java:104)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:799)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1036)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at java.util.TimerThread.run(Timer.java:505)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.128 |         at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:197)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:166)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:806)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1036)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.run(Timer.java:505)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.BinaryJedis.getDB(BinaryJedis.java:3343)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.JedisFactory.activateObject(JedisFactory.java:104)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:799)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1036)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.run(Timer.java:505)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:197)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:166)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:806)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1036)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.run(Timer.java:505)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.BinaryJedis.quit(BinaryJedis.java:265)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.JedisFactory.destroyObject(JedisFactory.java:115)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.destroy(GenericObjectPool.java:897)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.evict(GenericObjectPool.java:793)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1036)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at java.util.TimerThread.run(Timer.java:505)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 | java.lang.NullPointerException
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2267)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:134)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.ensureIdle(GenericObjectPool.java:927)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:906)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.129 |         at org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor.run(BaseGenericObjectPool.java:1046)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.130 |         at java.util.TimerThread.mainLoop(Timer.java:555)
INFO   | jvm 1    | main    | 2020/07/10 16:48:03.130 |         at java.util.TimerThread.run(Timer.java:505)

Redis / Jedis Configuration

Pool configuration and Jedis configuration

JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(128);
    poolConfig.setMaxIdle(128);
    poolConfig.setMinIdle(16);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setTestOnReturn(true);
    poolConfig.setTestWhileIdle(true);
    poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis());
    poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis());
    poolConfig.setNumTestsPerEvictionRun(3);

new JedisCluster(nodes, connectionTimeout, soTimeout, maxAttempts, password, poolConfig);

Jedis version: 3.3.0

Redis version: 5.0

Java version: 8

mouadelfakir avatar Jul 10 '20 14:07 mouadelfakir

It's strange I'm having the exact same problem... again with the same configuration!! I've spent more than a week trying to figure out the problem.

Maybe it's worth mentionning that I'm running this config on a cluster of 4 client nodes.

marrafi avatar Jul 20 '20 09:07 marrafi

Dupe #2189

sazzad16 avatar Jan 19 '22 15:01 sazzad16

Update: The exception is not caused by Jedis. We discovered that the agent of our APM solution "elastic" was instrumenting our plateform with it's proper logic, thus not getting the fullStackTrace on logs.

The issue was fixed by the team. So updating the agent to latest version solved our problem.

marrafi avatar Jan 19 '22 15:01 marrafi