在使用JedisCluster进行测试时出现如下异常:
java.lang.NumberFormatException: For input string: "7004@17004"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at redis.clients.util.ClusterNodeInformationParser.getHostAndPortFromNodeLine(ClusterNodeInformationParser.java:38)
at redis.clients.util.ClusterNodeInformationParser.parse(ClusterNodeInformationParser.java:14)
at redis.clients.jedis.JedisClusterInfoCache.discoverClusterNodesAndSlots(JedisClusterInfoCache.java:43)
at redis.clients.jedis.JedisClusterConnectionHandler.initializeSlotsCache(JedisClusterConnectionHandler.java:52)
at redis.clients.jedis.JedisClusterConnectionHandler.<init>(JedisClusterConnectionHandler.java:37)
at redis.clients.jedis.JedisSlotBasedConnectionHandler.<init>(JedisSlotBasedConnectionHandler.java:16)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:48)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:35)
at redis.clients.jedis.JedisCluster.<init>(JedisCluster.java:27)
at com.taotao.jedis.TestJedis.testJedisCluster(TestJedis.java:56)
错误原因:
redis4.0.0的版本服务器,jredis使用的2.7.2,redis和jedis代码不兼容。
解决办法:
需要将jedis版本更换为2.9.0,再次测试正常显示。