最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Redis中Jedis版本升级后的问题总结
时间:2022-06-29 02:36:57 编辑:袖梨 来源:一聚教程网
最近因为jedis 2.1.0接口的一些问题,升级版本了版本,结果出现了一个诡异的问题;时常能正常启动,时常出现jedisPool初始化时 java.lang.IllegalArgumentException: hostname can’t be null
原因出在spring JedisPool构造参数上,之前spring的配置如下
明显是因为host没有注入,但时常又可以,诡异!!!之后弄了jedis源码,加了日志,才定位到原因,查看JedisPool源码,其中的两构造函数如下
public JedisPool(final GenericObjectPoolConfig poolConfig, final String host, final int port) { this(poolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE, null); } public JedisPool(final GenericObjectPoolConfig poolConfig, final URI uri, final int timeout) { super(poolConfig, new JedisFactory(uri.getHost(), uri.getPort(), timeout, JedisURIHelper.getPassword(uri), JedisURIHelper.getDBIndex(uri) != null ? JedisURIHelper.getDBIndex(uri) : 0, null)); }
我们调用的是第一个构造函数,但事实是可能会调用第二个构造函数;port当做了timeout,host当做了URI。
不是很明白spring为什么会把value是字符串的参数匹配到URI上,那就明确指定类型吧
jedis之前的异常为,方面遇到同问题的同学
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:50) at redis.clients.jedis.JedisPool.getResource(JedisPool.java:88) at com.renhenet.modules.redis.RedisService.getHash(RedisService.java:364) at com.renhenet.modules.member.MemberRedisService.getMemberIndustryByMemberId(MemberRedisService.java:240) at com.renhenet.modules.member.MemberService.getMemberIndustry(MemberService.java:236) at com.renhenet.modules.member.MemberService$$FastClassByCGLIB$$b34212a.invoke() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631) at com.renhenet.modules.member.MemberService$$EnhancerByCGLIB$$1638ea72.getMemberIndustry( ) at com.renhenet.fw.struts2.interceptor.LoginRenheInterceptor.intercept(LoginRenheInterceptor.java:68) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) at com.renhenet.fw.struts2.interceptor.WebRenheInterceptor.intercept(WebRenheInterceptor.java:27) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) at com.renhenet.fw.struts2.filter.RenheStruts2Filter.doFilter(RenheStruts2Filter.java:32) at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265) at com.caucho.server.hmux.HmuxRequest.handleRequest(HmuxRequest.java:436) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682) at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:730) at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:649) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: hostname can't be null at java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149) at java.net.InetSocketAddress. (InetSocketAddress.java:216) at redis.clients.jedis.Connection.connect(Connection.java:142) at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:75) at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1572) at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:69)
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21