Announcement Announcement Module
Collapse
No announcement yet.
Spring Data Redis (Jedis) : ClassCastException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Redis (Jedis) : ClassCastException

    I'm using latest Spring Data Redis (1.0.1.RELEASE) on Tomcat 7. In addition, I'm using the Jedis connector, along with use-pool set to 'true'. My spring config stuff is defined in a standard way as per documentation.

    My issue is that I'm getting sporadic ClassCastExceptions, e.g:
    Code:
    java.lang.ClassCastException: [B cannot be cast to java.util.List 
    at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:206) 
    at redis.clients.jedis.BinaryTransaction.exec(BinaryTransaction.java:28)
    or

    Code:
    java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.Long
    at redis.clients.jedis.Connection.getIntegerReply(Connection.java:188)
    at redis.clients.jedis.Jedis.publish(Jedis.java:1978)
    From reading Jedis newsgroup, it looks like those can occur if a 'dirty' Jedis instance is released back into the pool (usually during broken pipeline operations). I'm using Spring Data Redis as follows:

    Code:
    		RedisConnectionFactory factory = template.getConnectionFactory();
    		RedisConnection conn = factory.getConnection();
    		Jedis jedis = (Jedis)conn.getNativeConnection();	
    		
    		try{
    			Pipeline p = jedis.pipelined();
    
    			//More jedis stuff goes here
    
    			p.sync();
    		}catch(Exception e){
    			e.printStackTrace();
    		}finally{
    			RedisConnectionUtils.releaseConnection(conn, factory);
    		}
    It looks like, RedisConnectionUtils.releaseConnection may not in fact, clean up, broken jedis instance - in which case, is there a proper way to disposing of jedis instances? I understand this isn't quite the standard way of using RedisTemplate wrapper.
Working...
X