-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
AnnotationsScanner throws NPE due to because AnnotatedElement proxy is not cloning arrays #22655
Comments
@philwebb, do you have time to look into this one as well? |
Similar issued reported by another user:
|
This has been bugging me in my review of the new arrangement already: Ignored annotations are nulled out in the annotations array. I left it in place for the time being but really prefer this being replaced with a correspondingly shrinked new array which never contains null entries. @philwebb, unless there was some specific reasoning behind reusing the original arrays, a shrinked array seems much safer, in particular for externally exposed annotation arrays? |
@jhoeller The main reason was to reduce GC pressure and improve performance. I figured it would be best not to need the array copy (but I admit I've not done testing with a copy in place). |
@philwebb On a related note, in my immediate revision that came with the merge, I've changed the rule for ignoring annotations to include |
Indeed, the |
Actually, this one is a little odd. The array in question isn't ours, it's a result of calling |
I've pushed a fix for master. Although it doesn't surface an NPE, the issue also exists in previous branches so I'll reopen for @jhoeller to consider a backport. |
source.getDeclaredAnnotations()
returns an array with null elements
Since the user-level recommendation is to not modify those arrays and we're not defensively copying them in That said, generally speaking for an |
This affects 5.2.0BUILD-SNAPSHOT, specifically 5.2.0-BUILD-20190325.085048
Spring Data JDBC integration tests started failing with the stack trace below.
The reason is that this line: https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/core/annotation/AnnotationsScanner.java#L448
throws an NPE because the array
annotations
contains a null element.The issue can be reproduced by running
mvn clean install
on master of spring-data-jdbc.Sorry, couldn't pin the issue down more precisely so far.
CI builds show that it worked last Friday. (20190322...)
The text was updated successfully, but these errors were encountered: