Summary of the problems after the Jedis version upgrade in Redis

Source: Internet
Author: User
Tags aop redis


Recently, because of the Jedis 2.1.0 interface problems, the upgrade version of the version, the result of a strange problem; often can start normally, often appear jedispool initialization java.lang.IllegalArgumentException: Hostname can ' t be null

The reason for this is the spring Jedispool constructor parameter, where spring is configured as follows

<bean id= "Jedispool" class= "Redis.clients.jedis.JedisPool" >

<constructor-arg ref= "Jedisconfig"/>< c1/> <constructor-arg value= "${redis.host}"/> <constructor-arg "

int" type= "value=}" ${redis.port

</bean>
Obviously because the host did not inject, but often can, strange!!! After the Jedis source code, added a log, to locate the reason, view Jedispool source code, the two constructors are as follows
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);

}
We call the first constructor, but the fact is that the second constructor may be invoked; Port as a timeout,host as a URI.

It's not clear why spring would match the parameter of value to a URI, so specify the type.

<bean id= "Jedispool" class= "Redis.clients.jedis.JedisPool" >

<constructor-arg ref= "Jedisconfig"/>< c1/> <constructor-arg type= "java.lang.String" value= "${redis.host}"/> <constructor-arg type=

"int" Val Ue= "${redis.port}"/>

</bean>

Jedis before the exception for, aspects encountered with the problem of the classmate

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 $ $b 34212a.invoke ( <generated>)         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 (<generated> )         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 :         at com.caucho.server.webapp.webappfilterchain.dofil)ter (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)     &nbsP;   at java.net.inetsocketaddress.<init> (inetsocketaddress.java:216)          at redis.clients.jedis.connection.connect (Connection.java:142)          at redis.clients.jedis.binaryclient.connect (BinaryClient.java :         at redis.clients.jedis.binaryjedis.connect ( binaryjedis.java:1572)         at  Redis.clients.jedis.JedisFactory.makeObject (jedisfactory.java:69)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.