Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE thrown when calling methods with an empty @Caching annotation [SPR-14162] #18734

spring-issuemaster opened this issue Apr 12, 2016 · 1 comment


Copy link

@spring-issuemaster spring-issuemaster commented Apr 12, 2016

Lev Bornovalov opened SPR-14162 and commented

To reproduce:

Call the following proxied method:

public void someMethod(final String argument) {

This will cause the following exception:

java.lang.NullPointerException: null
	at java.util.ArrayList.addAll( ~[na:1.8.0_20]
	at org.springframework.cache.annotation.SpringCacheAnnotationParser.parseCacheAnnotations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.SpringCacheAnnotationParser.parseCacheAnnotations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource$2.getCacheOperations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource.determineCacheOperations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource.findCacheOperations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.AbstractFallbackCacheOperationSource.computeCacheOperations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.AbstractFallbackCacheOperationSource.getCacheOperations( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.CacheOperationSourcePointcut.matches( ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at ~[spring-aop-4.2.3.RELEASE.jar:4.2.3.RELEASE]

Although you may be thinking that including an empty @Caching annotation is a corner-case, in our particular use-case, it's required, as we're calling a custom implementation of org.springframework.cache.interceptor.CacheInterceptor. We are doing this because the @CacheEvict funtionality does not allow use to easily purge individual keys based on method args, etc...

Affects: 3.2.16, 4.2.3

Issue Links:

  • #18663 @RequestHeader HttpHeaders fails with NPE against null header value

Referenced from: commits 3d6b0ca, da11261, 33dcef3

Backported to: 3.2.17

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 12, 2016

Juergen Hoeller commented

Good catch! We're explicitly checking for null there now. Feel free to give the upcoming 4.3.0.BUILD-SNAPSHOT or 4.2.6.BUILD-SNAPSHOT a try...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.