Skip to content

Random NegativeArraySizeExceptions from AOP-driven getMethod call on JDK 8 [SPR-12917] #17516

Closed

Description

@spring-projects-issues

Greg Adams opened SPR-12917 and commented

We're seeing random NegativeArraySizeException from Spring AOP when running with jdk 1.8 on linux (centos).

For us these are all in stacktraces including CacheOperationSourcePointcut from the spring caching abstraction support, but I've seen a similar report on stackoverflow regarding the @Transactional interceptor.

Occasionally, these exceptions result in a jvm crash with core dump. Oracle support opened an openjdk bug about this here:

https://bugs.openjdk.java.net/browse/JDK-8076521

but I think it's possible this may be a Spring AOP bug instead of a JDK bug. Downgrading to JDK 1.7 makes this issue go away. Also note that we are unable to reproduce this exception at will, since the exact same code works the vast majority of the time. We can only find these via production monitoring, where I believe it happens just due to the sheer number of requests served over a long period of time.

stacktrace

java.lang.Class.getDeclaredMethods0 (Native Method)

              java.lang.Class.privateGetDeclaredMethods (Class.java:2701)

              java.lang.Class.privateGetMethodRecursive (Class.java:3048)

                             java.lang.Class.getMethod0 (Class.java:3018)

                              java.lang.Class.getMethod (Class.java:1784)

….springframework.util.ClassUtils.getMostSpecificMethod (ClassUtils.java:768)

…actFallbackCacheOperationSource.computeCacheOperations (AbstractFallbackCacheOperationSource.java:135)

…bstractFallbackCacheOperationSource.getCacheOperations (AbstractFallbackCacheOperationSource.java:100)

…cache.interceptor.CacheOperationSourcePointcut.matches (CacheOperationSourcePointcut.java:39)

 org.springframework.aop.support.MethodMatchers.matches (MethodMatchers.java:94)

…ainFactory.getInterceptorsAndDynamicInterceptionAdvice (DefaultAdvisorChainFactory.java:67)

…sedSupport.getInterceptorsAndDynamicInterceptionAdvice (AdvisedSupport.java:489)

…pringframework.aop.framework.JdkDynamicAopProxy.invoke (JdkDynamicAopProxy.java:193)

        com.sun.proxy.$Proxy133.getCartShippingEstimate (Unknown Source)

 com.build.service.cart.CartServiceImpl.getLeadTimeText (CartServiceImpl.java:1926)

…m.build.service.order.OrderServiceImpl.getOrderReceipt (OrderServiceImpl.java:2157)

   com.build.service.order.OrderServiceImpl.cancelOrder (OrderServiceImpl.java:2341)

The DAO method being called by CartServiceImpl.getLeadTimeText actually does not have @Cacheable or any other caching annotations. However, one of our @Configuration classes has @EnableCaching, which I believe applies the caching interceptor to all proxies.

in case it's helpful, a core dump from one of the jvm crashes is here:
https://www.dropbox.com/s/ixnm3d7g7rneau4/core_1421.tgz?dl=0


Affects: 4.1.5

Reference URL: http://stackoverflow.com/questions/29311288/java-lang-negativearraysizeexception-from-spring-cache

Activity

  1. spring-projects-issues commented on Apr 15, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    I'm afraid this is indeed a JDK 8 bug. After all, that array size exception comes from within a Class.getMethod call. I have no idea what we could be doing differently there, we're just performing an innocent getMethod call, after all? We have no control over the internally cached Method array within the Class instance there and can't defensively handle the index either since we're not even specifying it ourselves...

    Juergen

  2. spring-projects-issues commented on Apr 15, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    I'm marking this as invalid for the time being. If there is anything we can do about it, even temporarily until the bug gets fixed in the JDK, we may reopen the issue. I just have a hard time coming up with a proper workaround even.

    Juergen

  3. spring-projects-issues commented on Apr 15, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Greg Adams commented

    That's what I was afraid of. Thanks for taking a look at it.

  4. spring-projects-issues commented on May 25, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Damien Hollis commented

    Hi Greg, we have the same problem and I noticed on the JDK bug report that the newrelic agent was being used. As luck would have it, we upgraded one of our environments to java 8 a few weeks ago but did not upgrade the newrelic agent. We upgraded the newrelic agent overnight and now this issue has started. So I suspect that the newrelic agent is somehow causing the issue. Can you confirm you are using newrelic?

    I will update the JDK issue too and raise an newrelic.

  5. spring-projects-issues commented on May 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Greg Adams commented

    Yes, we are using the newrelic agent.

  6. added
    type: bug
    status: invalid
    in: core
    on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: corestatus: invalid

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions