null指针异常

ttp71kqs  于 2021-06-09  发布在  Redis
关注(0)|答案(1)|浏览(450)

我的日志里充满了绝地武士的例外,即使是日志级别的信息我也不能忽略
加载缓冲区花费了2942毫秒:redis.clients.jedis.binaryjedis.ping(binaryjedis)上的java.lang.nullpointerexception。java:187)在redis.clients.jedis.jedisfactory.validateobject(jedisfactory。java:152)在org.apache.commons.pool2.impl.genericobjectpool.returnobject(genericobjectpool。java:534)在redis.clients.jedis.util.pool.returnresourceobject(池。java:68)在redis.clients.jedis.jedispool.returnresource(jedispool。java:251)在redis.客户.绝地.绝地.接近(绝地。java:3505)在com.puls.availability.services.availabilityserviceimpl.getavailabilitybufferpervertical(availabilityserviceimpl。java:360)在java.base/java.lang.thread.run(线程。java:834)redis.clients.jedis.binaryjedis.quit(binaryjedis)上的java.lang.nullpointerexception。java:255)在redis.clients.jedis.jedisfactory.destroyobject(jedisfactory。java:99)在org.apache.commons.pool2.impl.genericobjectpool.destroy(genericobjectpool。java:927)在org.apache.commons.pool2.impl.genericobjectpool.evict(genericobjectpool。java:768)在org.apache.commons.pool2.impl.basegenericobjectpool$exector.run(basegenericobjectpool。java:1138)在java.base/java.util.concurrent.executors$runnableadapter.call(executors。java:515)在java.base/java.util.concurrent.futuretask.runandreset(futuretask。java:305)在java.base/java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor。java:305)位于java.base/java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor。java:1128)在java.base/java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor。java:628)在java.base/java.lang.thread.run(线程。java:834)redis.clients.jedis.binaryjedis.quit(binaryjedis)上的java.lang.nullpointerexception。java:255)在redis.clients.jedis.jedisfactory.destroyobject(jedisfactory。java:99)在org.apache.commons.pool2.impl.genericobjectpool.destroy(genericobjectpool。java:927)在org.apache.commons.pool2.impl.genericobjectpool.evict(genericobjectpool。java:768)在org.apache.commons.pool2.impl.basegenericobjectpool$exector.run(basegenericobjectpool。java:1138)在java.base/java.util.concurrent.executors$runnableadapter.call(executors。java:515)在java.base/java.util.concurrent.futuretask.runandreset(futuretask。java:305)在java.base/java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor。java:305)位于java.base/java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor。java:1128)在java.base/java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor。java:628)在java.base/java.lang.thread.run(线程。java:834)redis.clients.jedis.binaryjedis.quit(binaryjedis)上的java.lang.nullpointerexception。java:255)在redis.clients.jedis.jedisfactory.destroyobject(jedisfactory。java:99)在org.apache.commons.pool2.impl.genericobjectpool.destroy(genericobjectpool。java:927)在org.apache.commons.pool2.impl.genericobjectpool.evict(genericobjectpool。java:768)在org.apache.commons.pool2.impl.basegenericobjectpool$exector.run(basegenericobjectpool。java:1138)在java.base/java.util.concurrent.executors$runnableadapter.call(executors。java:515)在java.base/java.util.concurrent.futuretask.runandreset(futuretask。java:305)在java.base/java.util.concurrent.scheduledthreadpoolexecutor$scheduledfuturetask.run(scheduledthreadpoolexecutor。java:305)位于java.base/java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor。java:1128)在java.base/java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor。java:628)在java.base/java.lang.thread.run(线程。java:834)
我的池配置是:

final 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 JedisPool(poolConfig, host, port, 1000);

它从哪里来?

vq8itlhq

vq8itlhq1#

使这个问题难以解决的是例外的隐藏部分,
异常应该如下所示:

load technicians buffer took 2942 miliseconds : java.lang.NullPointerException 
at co.elastic.apm.agent.redis.RedisSpanUtils.createRedisSpan(RedisSpanUtils.java:xxx)
at redis.clients.jedis.BinaryJedis.ping(BinaryJedis.java:187) 
at redis.clients.jedis.JedisFactory.validateObject(JedisFactory.java:152) 
at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:534) 
at redis.clients.jedis.util.Pool.returnResourceObject(Pool.java:68) 
at redis.clients.jedis.JedisPool.returnResource(JedisPool.java:251) 
at redis.clients.jedis.Jedis.close(Jedis.java:3505) 
at .....

原始异常中缺少此行: co.elastic.apm.agent.redis.RedisSpanUtils.createRedisSpan(RedisSpanUtils.java:) 该异常发生在elastic的javaapm代理中,但由于该代理使用java的instrumentation api,因此没有跟踪该异常。
在等待elastic解决问题时,您可以禁用代理监听redis请求。

相关问题