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

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

Comments

@spring-issuemaster
Copy link
Collaborator

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

Lev Bornovalov opened SPR-14162 and commented

To reproduce:

Call the following proxied method:

@Caching
public void someMethod(final String argument) {
   ....
}

This will cause the following exception:

java.lang.NullPointerException: null
	at java.util.ArrayList.addAll(ArrayList.java:577) ~[na:1.8.0_20]
	at org.springframework.cache.annotation.SpringCacheAnnotationParser.parseCacheAnnotations(SpringCacheAnnotationParser.java:89) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.SpringCacheAnnotationParser.parseCacheAnnotations(SpringCacheAnnotationParser.java:58) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource$2.getCacheOperations(AnnotationCacheOperationSource.java:124) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource.determineCacheOperations(AnnotationCacheOperationSource.java:142) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.annotation.AnnotationCacheOperationSource.findCacheOperations(AnnotationCacheOperationSource.java:121) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.AbstractFallbackCacheOperationSource.computeCacheOperations(AbstractFallbackCacheOperationSource.java:136) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.AbstractFallbackCacheOperationSource.getCacheOperations(AbstractFallbackCacheOperationSource.java:97) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.cache.interceptor.CacheOperationSourcePointcut.matches(CacheOperationSourcePointcut.java:39) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.aop.support.MethodMatchers.matches(MethodMatchers.java:94) ~[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

@spring-issuemaster

This comment has been minimized.

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
Projects
None yet
2 participants
You can’t perform that action at this time.