Announcement Announcement Module
Collapse
No announcement yet.
Question About RedisAtomicLong class to operate method getAndIncrement Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question About RedisAtomicLong class to operate method getAndIncrement

    I'm using Spring Data Key-Value 1.0.0.M2.
    In applicationContext-dataSource.xml:
    HTML Code:
    <bean id="jedisConnectionFactory" class="org.springframework.data.keyvalue.redis.connection.jedis.JedisConnectionFactory">
    <property name="hostName" value="${jdbc.redis.hostname}"></property>
    <property name="port" value="${jdbc.redis.port}"></property>
    </bean>

    In my DAO, I just write some toy lines to hava a try:
    Code:
    RedisAtomicInteger a = new RedisAtomicInteger("a:a", this.jedisConnectionFactory, 0);
    int[] alists = new int[] { a.get(), a.getAndAdd(1), a.getAndIncrement(), a.incrementAndGet() };
    for(int i : alists) {
    System.out.println(i);
    }

    I got this error on a.getAndIncrement(), stack trace says:
    redis.clients.jedis.exceptions.JedisDataException: ERR value is not an integer or out of range
    redis.clients.jedis.Protocol.processError(Protocol .java:55)
    redis.clients.jedis.Protocol.process(Protocol.java :62)
    redis.clients.jedis.Protocol.processMultiBulkReply (Protocol.java:117)
    redis.clients.jedis.Protocol.process(Protocol.java :64)
    redis.clients.jedis.Protocol.read(Protocol.java:12 3)
    redis.clients.jedis.Connection.getObjectMultiBulkR eply(Connection.java:189)
    redis.clients.jedis.BinaryTransaction.exec(BinaryT ransaction.java:417)
    org.springframework.data.keyvalue.redis.connection .jedis.JedisConnection.exec(JedisConnection.java:5 10)
    org.springframework.data.keyvalue.redis.core.Redis Template$1.doInRedis(RedisTemplate.java:573)
    org.springframework.data.keyvalue.redis.core.Redis Template.execute(RedisTemplate.java:205)
    org.springframework.data.keyvalue.redis.core.Redis Template.execute(RedisTemplate.java:175)
    org.springframework.data.keyvalue.redis.core.Redis Template.execute(RedisTemplate.java:148)
    org.springframework.data.keyvalue.redis.core.Redis Template.execute(RedisTemplate.java:136)
    org.springframework.data.keyvalue.redis.core.Redis Template.exec(RedisTemplate.java:569)
    org.springframework.data.keyvalue.redis.support.at omic.CASUtils$1.execute(CASUtils.java:59)
    org.springframework.data.keyvalue.redis.core.Redis Template.execute(RedisTemplate.java:244)
    org.springframework.data.keyvalue.redis.support.at omic.CASUtils.execute(CASUtils.java:51)
    org.springframework.data.keyvalue.redis.support.at omic.RedisAtomicInteger.getAndIncrement(RedisAtomi cInteger.java:178)
    com.xshia.gabriel.GabrielForJustice.JusticeForTest (GabrielForJustice.java:127)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:426)
    org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:414)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    org.springframework.web.filter.HiddenHttpMethodFil ter.doFilterInternal(HiddenHttpMethodFilter.java:7 7)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 312)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:116)
    org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:95)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:100)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:79)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.authentication.re memberme.RememberMeAuthenticationFilter.doFilter(R ememberMeAuthenticationFilter.java:112)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:35)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:187)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.context.SecurityC ontextPersistenceFilter.doFilter(SecurityContextPe rsistenceFilter.java:80)
    org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 324)
    org.springframework.security.web.FilterChainProxy. doFilter(FilterChainProxy.java:165)
    org.springframework.web.filter.DelegatingFilterPro xy.invokeDelegate(DelegatingFilterProxy.java:237)
    org.springframework.web.filter.DelegatingFilterPro xy.doFilter(DelegatingFilterProxy.java:167)
    Did I miss something or just hava a wrong instantiation of a RedisAtomicInteger object? I checked the source but couldn't find anything helpful...Can anybody post some examples or just tell me where I made a mistake..I'll really appreciate it.

  • #2
    Your code is correct - this is an actual bug in M2. Can you please try the current trunk/SNAPSHOT - the home page has all the information (including Maven repo)?

    Cheers,

    Comment

    Working...
    X