zzsoszz / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

EhCacheInterceptor initialized with null cache under high load #104

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Run the attached testcase. It illustrates the problem. Every time "GOT ONE!!" 
is printed to the console, the problem has manifested itself

What is the expected output? What do you see instead?

When using DefaultCacheResolverFactory with createCaches set to true in a high 
load scenario it can happen that multiple threads will try and create a non 
existing cache in parallel. In this case the EhCacheInterceptor should still be 
initialized properly but this is not always the case. We where seeing the 
following exception in the logs :

marketplace-server: java.lang.NullPointerException: null
marketplace-server:     at 
com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor.invokeCacheabl
e(EhCacheInterceptor.java:129) ~[ehcache-spring-annotations-1.2.0.jar:1.2.0]
marketplace-server:     at 
com.googlecode.ehcache.annotations.interceptor.EhCacheInterceptor.invoke(EhCache
Interceptor.java:81) ~[ehcache-spring-annotations-1.2.0.jar:1.2.0]
marketplace-server:     at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveM
ethodInvocation.java:172) ~[spring-aop-3.1.3.RELEASE.jar:3.1.3.RELEASE]
marketplace-server:     at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.j
ava:202) ~[spring-aop-3.1.3.RELEASE.jar:3.1.3.RELEASE]
marketplace-server:     at 
$Proxy112.getNonNumericAndNumericAttributesForCategory(Unknown Source) ~[na:na]

What version of the product are you using? On what operating system?

We are using ehcache-spring-annotations-1.2.0. The attached code was tested on 
a macbook pro 2.6ghz intel core i7, 16gig, running OSX 10.8.5

Original issue reported on code.google.com by jkupe...@gmail.com on 4 Dec 2013 at 7:50

Attachments:

GoogleCodeExporter commented 9 years ago
It is actually because the addCache method of net.sf.ehcache. CacheManager was 
not threadsafe in ehcache < 2.6.2 they changed that as part of 
https://jira.terracotta.org/jira/browse/EHC-970. Upgrading ehcache is the 
easiest solution. Alternatively you can create your own instance of 
CacheResolverFactory that synchronizes the on itself before calling addCache 

Original comment by jkupe...@gmail.com on 18 Jan 2014 at 10:46