-
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
MergedAnnotation swallows IllegalAccessException for attribute method #27182
Comments
Down in the bowels of boolean isValid(Annotation annotation) {
this.assertAnnotation(annotation);
for(int i = 0; i < this.size(); ++i) {
if (this.canThrowTypeNotPresentException(i)) {
try {
this.get(i).invoke(annotation);
} catch (Throwable var4) {
return false;
}
}
}
return true;
} The exception thrown here is swallowed, but it gives the exact action necessary to avoid it.
|
Exception looks like this:
|
What happens if you add a suitable |
Then it works fine. But because the original exception is swallowed and results in an NPE, what should be a trivial diagnosis becomes an extended session in the debugger. |
The given scenario has effectively been addressed through #29448 already, avoiding reflection for annotation attribute retrieval to begin with. Even non-exported annotation types can be introspected for certain purposes that way, not leading to IllegalAccessExceptions in regular scenarios. I have nevertheless revised IllegalAccessException handling for the fallback reflection code path there. As a bonus, we also avoid reflection for TypeVariable comparisons now (which typically happen during annotation retrieval on common classes and methods), and we log a clearer-worded message for annotation attribute retrieval failure at info level (e.g. on Google App Engine in case of a late-occurring TypeNotPresentException, logged at the same level as an early-occurring TypeNotPresentException on a regular JVM now). |
AnnotationBasedPersistentProperty.validateAnnotation NullPointerException on project-specific annotations.
I hit this when running the tests of spring-data-couchbase project with JDK11 and adding a java-module.java. I assume there is some sort of introspection failure.
mergedAnnotation passed into validateAnnotation and the NPE occurs when candidate is dereferenced.
https://github.com/spring-projects/spring-data-commons/blob/db8431ee41b3b73dd87364de9c6cff158790452e/src/main/java/org/springframework/data/mapping/model/AnnotationBasedPersistentProperty.java#L125
It's the .orElse((Object)null) that gets returned.
The text was updated successfully, but these errors were encountered: