redis Unexpected end of stream异
2018-06-08 本文已影响0人
xcardata

jedis提供链接池 使用的是apache common pool的第三方jar包,
在有些监控系统中会报Unexpected end of stream.错误,如上图所示
GenericObjectPool.borrowObject方法是真正从pool中取连接对像的方法。
JedisPoolConfig的设置如下:

设置了conf.setTestOnBorrow(true); 在取对象时设置可用性验证,
每次取出来之前都要进行ping操作,即调用 JedisFactory.activateObject方法,如图1所示。
activateObject会等待RedisInputStream.ensureFill方法的返回信息,如果服务redisserver返回值不是正确就会报Unexpected end of stream异常。
但这并不影响客户端的使用,borrowObject方法源代码中

while(p == null) 会再次从blockqueue中取,如果在超时时间内未取得再报exception