[Jedis] ERR wrong number of arguments for 'mget'
看别人写的代码是件比较痛苦的事情,更加痛苦的是别人的代码出错还要负责调试好。
关于如何迅速定位问题和调试代码,我的一点感受是:逐行认真查看错误信息,在这些信息中找自己熟悉的内容(包括文件名、方法名等),不熟悉的内容先跳过。针对这些熟悉的内容,回溯相应的代码所在行,定位错误原因。
切忌囫囵吞枣的看了一通,其实什么有效信息也没有获得,也几乎不可能就这样定位到问题。
举例:
1、定位问题
在使用jedis监听和订阅消息时报以下错误。经逐行查看错误信息,定位到斜体的三行:分析错误原因是mget调用出错,且错误代码在OnlineFriend文件的112/257行。
redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'mget' command
at redis.clients.jedis.Protocol.processError(Protocol.java:59) at redis.clients.jedis.Protocol.process(Protocol.java:66)
at redis.clients.jedis.Protocol.read(Protocol.java:131)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:188)
at redis.clients.jedis.Jedis.mget(Jedis.java:873)
at com.caffinc.OnlineFriend$MsgListener.onMessage(OnlineFriend.java:112)
at com.caffinc.OnlineFriend.main(OnlineFriend.java:257)
出错代码如下:List topRoles = jedis.srandmember(top_set_key, 10);
List topLevels = jedis.mget(topRoles.toArray(new String[0]));
2、检查问题
根据以上代码,分析可能原因是jedis.mget(key)方法没有获取到key值,即key为空。
直接在redis-cli中运行> srandmember top_set_key,发现top_set_key集合为空,并由此导致mget方法参数缺失。
3、问题处理
导入相应数据到redis top_set_key集合,重新运行代码后一切正常。
总结下,有两点收获:一是调试代码要逐行认真看错误信息,不可囫囵吞枣;二是具体到技术点,mget如果参数为空,会导致ERR wrong number of arguments for 'mget' 错误。
[Jedis] ERR wrong number of arguments for 'mget'的更多相关文章
- redis cluster 的ERR max number of clients reached 问题排查
早上发现微服务连不上redis cluster了,看来下日志如下 [root@win-jrh378d7scu 7005]# bin/redis-cli -c -h 15.31.213.183 -p 7 ...
- wrong number of arguments,java方法反射时数组参数的坑
java方法中只有一个参数是数组,反射的时候我们不能想当然的传歌数组进去,传数组进去的时候表示多个参数. 两个数组不是一个意思啊. 我们应该把数组转为objet,这样才表示一个参数. import j ...
- Error Code: 1318. Incorrect number of arguments for PROCEDURE company.new_procedure; expected 2, got
1.错误叙述性说明 20:27:34 call new_procedure(20150112) Error Code: 1318. Incorrect number of arguments for ...
- Error Code: 1318. Incorrect number of arguments for PROCEDURE student.new_procedure; expected 0, got
1.错误描述 13:58:20 call new_procedure('2000','zhangsan') Error Code: 1318. Incorrect number of argument ...
- Variable number of arguments (Varargs)
A parameter of a function (normally the last one) may be marked with vararg modifier: fun <T> ...
- hbase ERROR: wrong number of arguments (3 for 4)
hbase(main):036:0> get 'ddl', 'example', 'info:age'COLUMN ...
- 反射报错java.lang.IllegalArgumentException: wrong number of arguments
class Person{ private String name ; private String sex ; public Person(){ System.out.println("c ...
- [nginx]invalid number of arguments
invalid number of arguments nginx出现以下的错误,基本上错误的原因就是少了后面的分号导致. invalid number of arguments
- Lua 变长参数(variable number of arguments)
lua变长参数 function add ( ... ) for i, v in ipairs{...} do print(i, ' ', v) end end add(1, 2, 'sdf') lu ...
随机推荐
- oracle错误整理
1. ORA-31640: unable to open dump file 解决:原来11g R2的IMPDP 增加了一个参数设置:CLUSTER,在设置了parallel参数>1的情况下, ...
- UI基础四:简单的assign block
经常会有需求让在标准的order加个assign block,那就来简单说一下: 1.创建assign block组件ZXXXXXX 2.添加BTORDER节点和GUID属性 3.创建表视图(可配置, ...
- git相关知识(github,idea等的配置)
本地git提交文件到github上: 1.在github上创建项目 2.使用git clone https://github.com/xxxxxxx/xxxxx.git克隆到本地 3.编辑项目 4.g ...
- [POJ题目分类][转]
Hint:补补基础... 初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治 ...
- flex布局文本过长不显示省略号
https://www.cnblogs.com/tgxh/p/6916930.html 解决方法: 给flex子元素添加css: white-space: nowrap; text-overflow: ...
- 一、Redis的数据类型
一Redis的数据类型 string:字符串 hash:哈希 list:列表 set:集合 zset:有序集合(sorted set) 1.string(字符串) redis最基本的类型.可以理解成与 ...
- ActiveMQ 的连接和会话
要了解 connection 和 session 的概念,可以先从 ConnectionState 和 SessionState 入手: // 省略部分代码 public class Connecti ...
- stealwatch里的安全功能——ETA结果会显示加密套件以及key长度,还有流量大小(例如41MB)
以后可以考虑的方向,在stealwatch里包含: ad Injector click fraud cryptocurrency miner exploit kit malicious adverti ...
- hashlib 库
hashlib 库 hash 是一种算法,用来接收一系列数据,经过计算后得到一个hash值 hash值的三大特征: 1. 如果传入的数据一样,得到的hash值一样 2. 只要采用的hash算法固定,无 ...
- vue 跳外链
var host = window.location.host;var protocal = window.location.protocolwindow.location.href = protoc ...