[Exception] JedisDataException: ERR wrong number of arguments for '***' command

异常信息:

Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'zrem' command
    at redis.clients.jedis.Protocol.processError(Protocol.java:66)
    at redis.clients.jedis.Protocol.process(Protocol.java:73)
    at redis.clients.jedis.Protocol.read(Protocol.java:138)
    at redis.clients.jedis.Connection.getIntegerReply(Connection.java:191)
    at redis.clients.jedis.Jedis.zrem(Jedis.java:1440)
    at com.gamejelly.gong.global.dbs.service.GlobalJedisService$26.doInJedis(GlobalJedisService.java:750)
    at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.execute(JedisTemplate.java:79)
    at com.gamejelly.gong.global.dbs.service.GlobalJedisService.delRedisKeys(GlobalJedisService.java:746)
    at com.gamejelly.gong.global.dbs.proxy.GlobalCommandProxy.delRedisKeys(GlobalCommandProxy.java:642)
    at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.hadoit.game.engine.core.utils.method.MethodInvoationWrap.invoke(MethodInvoationWrap.java:63)

示例代码:

public void rem(String key,String[] delkeys){
    jedis.zrem(key, delKeys);
}

原因:

jedis.zrem(key, delKeys)数组参数delkeys长度为0,即抛出该异常
注:jedis还有很多方法都会抛出该异常,原因与此一致。jedis 不定长度参数方法都有这个问题

解决方案:

在代码中合适处检查数组参数长度

你可能感兴趣的:(异常Throwable,redis)