Sriram Creator of geeky things, mostly unused junk

Jedis: ERR wrong number of arguments for ‘rpush’ command

While refactoring a large project with some legacy unmanageable code which used Redis, I came across this exception:

Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'rpush' command
    at redis.clients.jedis.Protocol.processError(
    at redis.clients.jedis.Protocol.process(
    at redis.clients.jedis.Connection.getIntegerReply(
    at redis.clients.jedis.Jedis.rpush(
    at com.caffinc.RedisCacheManager.storeDoubleList(

It was intermittent and used to appear only sometimes, and used to mess up the process. After pulling my hair out for a while, I discovered that passing an empty list to jCon.rpush( name, values ); causes this exception. Rather weird if you ask me. Empty lists are completely logical, and in most cases necessary. I handled this by simply checking if the list was empty before inserting into Redis.

I thought this would be all, as the problem did disappear for a while. But when I checked in my code after making some major refactoring, the problem returned! Try as I might, it this call kept failing and everything seemed fine on my machine locally…

I realized I’d upgraded Redis on my machine, and also Jedis in my code. I upgraded Redis from 2.2 on the server to 3.0.2 and things were working fine again!

comments powered by Disqus