Jedis errors

Jedis is a blazingly small and sane Redis java client

https://github.com/xetorthio/jedis
Solution coverage:
Summary coverage:

Top patterns

  1. Redis responded with an error code that is not processed by Jedis

    This exception can occur in different situations. For example.: Missing authentication parameter, etc.

  2. End of stream while reading Redis response

    There are multiple things to check when you have Jedis connection issues. A handful of tips are discussed in this GitHub issue:

    • call close() to return the Jedis instance to the pool (do not call returnResource())
    • catch JedisConnectionException for each Jedis command, and retrieve a new Jedis instance from the pool for the next Jedis commands to work (in the catch clause)
    • Change the timeout (in JedisPool constructor), because in my case, I retrieve a new Jedis instance at the beginning of the request and I return it at the end of the request. Because a request may last more than 2 seconds (not optimized code yet), the timeout needed to be greater
    • Change the pool max clients, but it must be lower than the redis maxclients in redis configuration
    • Change the pool max idle clients
    • Set testOnBorrow, testOnReturn and testWhildIdle to true for the JedisPool so that the connection to redis is validated often enough to avoid connection issues (all of these test methods may not be necessary but I used all of them and it works)
  3. Redis responded an error code that is unhandled by Jedis

    This exception can occur in different situations. For example.: Redis timeout, etc.


DescriptionException TypeEntry MethodWeb pages

Redis responded with an error code that is not processed by Jedis

redis.clients.jedis.exceptions.JedisDataException
redis.clients.jedis.Protocol.processError
99Web pages
1Solution
JedisDataExceptionProtocol.processError99

End of stream while reading Redis response

redis.clients.jedis.exceptions.JedisConnectionException
redis.clients.util.RedisInputStream.ensureFill
34Web pages
1Solution
JedisConnectionExceptionRedisInputStream.ensureFill34

Redis responded an error code that is unhandled by Jedis

redis.clients.jedis.exceptions.JedisConnectionException
redis.clients.jedis.Protocol.process
21Web pages
1Solution
JedisConnectionExceptionProtocol.process21

Too many redirections when connecting to Redis

redis.clients.jedis.exceptions.JedisClusterMaxRedirectionsException
1 frames hidden
redis.clients.jedis.JedisClusterCommand.runWithRetries
15Web pages
1Solution
JedisClusterMaxRedirectionsExceptionJedisClusterCommand.runWithRetries15

Redis closed the connection and Jedis got an empty response

redis.clients.jedis.exceptions.JedisConnectionException
redis.clients.util.RedisInputStream.readLine
14Web pages
JedisConnectionExceptionRedisInputStream.readLine14

Tried to use the same Jedis object in multiple Threads

java.lang.ClassCastException
redis.clients.jedis.Connection.getIntegerReply
14Web pages
1Solution
ClassCastExceptionConnection.getIntegerReply14

Jedis client uses an invalid connection

java.lang.ClassCastException
redis.clients.jedis.Connection.getBinaryMultiBulkReply
13Web pages
1Solution
ClassCastExceptionConnection.getBinaryMultiBulkReply13

Cannot read Redis status code reply as a byte array

java.lang.ClassCastException
redis.clients.jedis.Connection.getStatusCodeReply
12Web pages
ClassCastExceptionConnection.getStatusCodeReply12

Reading Redis response timed out

java.net.SocketTimeoutException
redis.clients.jedis.Protocol.process
8Web pages
SocketTimeoutExceptionProtocol.process8

Jedis write buffer overloaded.

java.lang.ArrayIndexOutOfBoundsException
1 frames hidden
redis.clients.jedis.Protocol.sendCommand
8Web pages
1Solution
ArrayIndexOutOfBoundsExceptionProtocol.sendCommand8

Cannot read Redis response as a byte array

java.lang.ClassCastException
redis.clients.jedis.BuilderFactory$5.build
8Web pages
1Solution
ClassCastExceptionBuilderFactory$5.build8

Cannot get a Redis connection from the pool

redis.clients.jedis.exceptions.JedisConnectionException
2 frames hidden
redis.clients.jedis.JedisClusterCommand.runWithRetries
7Web pages
JedisConnectionExceptionJedisClusterCommand.runWithRetries7

Connection.sendCommand() has thrown a SocketTimeoutException

java.net.SocketTimeoutException
2 frames hidden
redis.clients.jedis.Connection.sendCommand
6Web pages
SocketTimeoutExceptionConnection.sendCommand6

Jedis tried to return an invalidated connection

java.lang.IllegalStateException
1 frames hidden
redis.clients.util.Pool.returnBrokenResourceObject
6Web pages
IllegalStateExceptionPool.returnBrokenResourceObject6

Redis cluster is down

redis.clients.jedis.exceptions.JedisClusterException
1 frames hidden
redis.clients.jedis.Protocol.process
6Web pages
JedisClusterExceptionProtocol.process6

Using `multi()` in Pipeline wasn't supported in earlier Jedis version

java.lang.ClassCastException
3 frames hidden
redis.clients.jedis.Pipeline.syncAndReturnAll
4Web pages
ClassCastExceptionPipeline.syncAndReturnAll4

There is no reachable node in the cluster

redis.clients.jedis.exceptions.JedisNoReachableClusterNodeException
3 frames hidden
redis.clients.jedis.JedisClusterCommand.run
4Web pages
JedisNoReachableClusterNodeExceptionJedisClusterCommand.run4

The hash moved to a different Redis node

redis.clients.jedis.exceptions.JedisMovedDataException
2 frames hidden
redis.clients.jedis.Protocol.read
4Web pages
1Solution
JedisMovedDataExceptionProtocol.read4

JedisSlotBasedConnectionHandler.getConnectionFromSlot() has thrown a JedisConnectionException

redis.clients.jedis.exceptions.JedisConnectionException
2 frames hidden
redis.clients.jedis.JedisSlotBasedConnectionHandler.getConnectionFromSlot
4Web pages
JedisConnectionExceptionJedisSlotBasedConnectionHandler.getConnectionFromSlot4

Jedis cannot connect to Redis

java.net.ConnectException
redis.clients.jedis.Connection.connect
3Web pages
ConnectExceptionConnection.connect3

Redis output stream is uninitialized

java.lang.NullPointerException
2 frames hidden
redis.clients.jedis.Connection.sendCommand
3Web pages
NullPointerExceptionConnection.sendCommand3

Redis connection broken while sending a command

java.net.SocketException
redis.clients.jedis.Connection.flush
3Web pages
SocketExceptionConnection.flush3

Connection.sendCommand() has thrown a SocketException

java.net.SocketException
2 frames hidden
redis.clients.jedis.Connection.sendCommand
3Web pages
SocketExceptionConnection.sendCommand3

Pool.returnBrokenResourceObject() has thrown a JedisException

redis.clients.jedis.exceptions.JedisException
redis.clients.util.Pool.returnBrokenResourceObject
3Web pages
JedisExceptionPool.returnBrokenResourceObject3

Pong response is rejected by Jedis 2.7

redis.clients.jedis.exceptions.JedisException
redis.clients.jedis.JedisPubSub.process
2Web pages
1Solution
JedisExceptionJedisPubSub.process2

Jedis.subscribe() has thrown a JedisConnectionException

redis.clients.jedis.exceptions.JedisConnectionException
3 frames hidden
redis.clients.jedis.Jedis.subscribe
2Web pages
JedisConnectionExceptionJedis.subscribe2

Redis client is in Multi or Pipeline mode

redis.clients.jedis.exceptions.JedisDataException
redis.clients.jedis.BinaryJedis.checkIsInMultiOrPipeline
2Web pages
JedisDataExceptionBinaryJedis.checkIsInMultiOrPipeline2

Redis client is uninitialized when finalizing pipeline execution

java.lang.NullPointerException
redis.clients.jedis.Pipeline.syncAndReturnAll
2Web pages
NullPointerExceptionPipeline.syncAndReturnAll2

Jedis cannot process the response from Redis

redis.clients.jedis.JedisException
1 frames hidden
redis.clients.jedis.Protocol.read
2Web pages
JedisExceptionProtocol.read2

Response.get() has thrown a JedisDataException

redis.clients.jedis.exceptions.JedisDataException
redis.clients.jedis.Response.get
2Web pages
JedisDataExceptionResponse.get2

BinaryJedis.info() has thrown a JedisConnectionException

redis.clients.jedis.exceptions.JedisConnectionException
5 frames hidden
redis.clients.jedis.BinaryJedis.info
2Web pages
JedisConnectionExceptionBinaryJedis.info2

Cannot send command to Redis, it closed the connection

redis.clients.jedis.exceptions.JedisConnectionException
2 frames hidden
redis.clients.jedis.Connection.sendCommand
1Web pages
JedisConnectionExceptionConnection.sendCommand1

JBoss EAP 5.2 JMX incompatibility

javax.management.NotCompliantMBeanException
25 frames hidden
redis.clients.util.Pool.initPool
1Web pages
NotCompliantMBeanExceptionPool.initPool1

JedisSentinelPool.<init>() has thrown a JedisException

redis.clients.jedis.exceptions.JedisException
4 frames hidden
redis.clients.jedis.JedisSentinelPool.<init>
1Web pages
JedisExceptionJedisSentinelPool.<init>1

Jedis.set() has thrown a JedisConnectionException

redis.clients.jedis.exceptions.JedisConnectionException
5 frames hidden
redis.clients.jedis.Jedis.set
1Web pages
JedisConnectionExceptionJedis.set1

SafeEncoder.encode() has thrown a JedisDataException

redis.clients.jedis.exceptions.JedisDataException
redis.clients.util.SafeEncoder.encode
1Web pages
JedisDataExceptionSafeEncoder.encode1

JedisPool.getResource() has thrown a JedisConnectionException

redis.clients.jedis.exceptions.JedisConnectionException
9 frames hidden
redis.clients.jedis.JedisPool.getResource
0Web pages
JedisConnectionExceptionJedisPool.getResource0
Package namePatterns foundSolution coverageSummary coverage
redis.clients.jedis171
redis.clients.util29
Package nameClass namePatterns foundSolution coverageSummary coverage
redis.clients.jedisConnection60
redis.clients.jedisProtocol22
redis.clients.jedisBinaryJedis17
redis.clients.jedisJedisPool17
redis.clients.utilPool14
redis.clients.jedisJedis14
redis.clients.jedisBinaryClient9
redis.clients.utilRedisInputStream9
redis.clients.jedisJedisClusterCommand6
redis.clients.jedisPipeline5
redis.clients.jedisJedisCluster4
redis.clients.utilRedisOutputStream4
redis.clients.jedisResponse4
redis.clients.jedisJedisSlotBasedConnectionHandler3
redis.clients.jedisJedisFactory2
redis.clients.jedisBuilderFactory$52
redis.clients.utilSafeEncoder2
redis.clients.jedisJedisSentinelPool1
redis.clients.jedisHostAndPort1
redis.clients.jedisTransaction1
redis.clients.jedisJedisPubSub1
redis.clients.jedisBinaryShardedJedis1
redis.clients.jedisBinaryJedisCluster1
Package nameClass nameMethod namePatterns foundSolution coverage
redis.clients.jedisConnectionconnect14
redis.clients.jedisBinaryJedisconnect11
redis.clients.jedisProtocolprocess11
redis.clients.utilPoolgetResource10
redis.clients.jedisJedisPoolgetResource10
redis.clients.jedisConnectionreadProtocolWithCheckingBroken10
redis.clients.jedisConnectionsendCommand8
redis.clients.jedisBinaryClientconnect8
redis.clients.jedisProtocolread7
redis.clients.jedisConnectiongetBinaryMultiBulkReply7
redis.clients.utilRedisInputStreamensureFill6
redis.clients.jedisConnectiongetIntegerReply6
redis.clients.jedisPipelinesyncAndReturnAll4
redis.clients.jedisResponseget4
redis.clients.jedisJedisset4
redis.clients.jedisJedisClusterCommandrunWithRetries4
redis.clients.jedisJedisPoolreturnResource4
redis.clients.jedisConnectiongetStatusCodeReply3
redis.clients.jedisConnectionflush3
redis.clients.jedisProtocolsendCommand3
redis.clients.jedisJedisClusterset3
redis.clients.jedisJedisPool<init>2
redis.clients.utilPoolreturnBrokenResourceObject2
redis.clients.utilRedisOutputStreamflushBuffer2
redis.clients.jedisJedisClusterCommandrun2
redis.clients.jedisConnectiongetMultiBulkReply2
redis.clients.jedisBuilderFactory$5build2
redis.clients.utilSafeEncoderencode2
redis.clients.jedisJedissubscribe2
redis.clients.utilRedisInputStreamreadByte2
redis.clients.jedisJedisFactorymakeObject2
redis.clients.jedisConnectiongetAll2
redis.clients.jedisConnectiongetBinaryBulkReply2
redis.clients.jedisJedisSlotBasedConnectionHandlergetConnection1
redis.clients.jedisJedisPoolreturnBrokenResource1
redis.clients.jedisConnectiongetBulkReply1
redis.clients.jedisJedisttl1
redis.clients.jedisTransactionexec1
redis.clients.jedisBinaryJedisauth1
redis.clients.jedisJedisconfigSet1
redis.clients.jedisBinaryJedisselect1
redis.clients.jedisJedismget1
redis.clients.jedisJediswatch1
redis.clients.jedisJedishset1
redis.clients.jedisConnectiongetRawObjectMultiBulkReply1
redis.clients.jedisJedisPubSubprocess1
redis.clients.jedisJedisSlotBasedConnectionHandler<init>1
redis.clients.jedisJedisCluster<init>1
redis.clients.utilPoolinitPool1
redis.clients.jedisJedisexpire1
Package nameClass nameMethod nameException TypePatterns foundSolution coverage
redis.clients.utilPoolgetResourceJedisConnectionException9
redis.clients.jedisBinaryJedisconnectJedisConnectionException8
redis.clients.jedisJedisPoolgetResourceJedisConnectionException8
redis.clients.jedisConnectionreadProtocolWithCheckingBrokenJedisConnectionException8
redis.clients.jedisBinaryClientconnectJedisConnectionException7
redis.clients.jedisConnectionconnectJedisConnectionException7
redis.clients.jedisProtocolprocessJedisConnectionException7
redis.clients.jedisConnectiongetBinaryMultiBulkReplyJedisConnectionException5
redis.clients.jedisConnectiongetIntegerReplyJedisConnectionException5
redis.clients.jedisConnectionconnectConnectException4
redis.clients.jedisConnectionsendCommandJedisConnectionException4
redis.clients.jedisJedisPoolreturnResourceJedisException4
redis.clients.jedisJedisClusterCommandrunWithRetriesJedisConnectionException3
redis.clients.utilRedisInputStreamensureFillJedisConnectionException3
redis.clients.jedisProtocolreadJedisConnectionException3
redis.clients.jedisJedissubscribeJedisConnectionException2
redis.clients.jedisConnectiongetAllJedisConnectionException2
redis.clients.jedisPipelinesyncAndReturnAllClassCastException2
redis.clients.jedisJedissetJedisConnectionException2
redis.clients.jedisResponsegetClassCastException2
redis.clients.jedisPipelinesyncAndReturnAllNullPointerException2
redis.clients.jedisProtocolprocessSocketTimeoutException2
redis.clients.jedisJedisClustersetJedisClusterMaxRedirectionsException2
redis.clients.jedisBuilderFactory$5buildClassCastException2
redis.clients.utilRedisInputStreamensureFillSocketTimeoutException2
redis.clients.utilRedisOutputStreamflushBufferSocketException2
redis.clients.jedisProtocolsendCommandSocketException2
redis.clients.jedisConnectionconnectSocketTimeoutException2
redis.clients.jedisConnectiongetMultiBulkReplyJedisConnectionException2
redis.clients.jedisBinaryJedisconnectConnectException2
redis.clients.jedisConnectiongetBinaryBulkReplyJedisConnectionException2
redis.clients.jedisConnectionflushSocketException2
redis.clients.utilRedisInputStreamreadByteJedisConnectionException2
redis.clients.jedisJedisFactorymakeObjectJedisConnectionException2
redis.clients.jedisJedisPubSubprocessJedisException1
redis.clients.jedisProtocolreadJedisDataException1
redis.clients.jedisBinaryJedischeckIsInMultiOrPipelineJedisDataException1
redis.clients.jedisConnectionsendCommandSocketTimeoutException1
redis.clients.jedisJedisClusterCommandrunJedisNoReachableClusterNodeException1
redis.clients.jedisConnectiongetBinaryMultiBulkReplyClassCastException1
redis.clients.jedisJedisClusterCommandrunJedisClusterMaxRedirectionsException1
redis.clients.utilPoolreturnResourceObjectJedisException1
redis.clients.jedisBinaryClientconnectIllegalArgumentException1
redis.clients.utilRedisInputStreamreadLineJedisConnectionException1
redis.clients.jedisConnectionsendCommandNullPointerException1
redis.clients.utilPoolreturnBrokenResourceObjectIllegalStateException1
redis.clients.utilPoolinitPoolNotCompliantMBeanException1
redis.clients.jedisConnectiongetIntegerReplyClassCastException1
redis.clients.jedisJedissetJedisMovedDataException1
redis.clients.jedisJedisClusterCommandrunWithRetriesJedisClusterMaxRedirectionsException1