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

AnnotatedElementUtils.getAllAnnotationAttributes(…, "javax.annotation.Nonnull") returns null #22696

Closed
Tracked by #22560
mp911de opened this issue Mar 28, 2019 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Milestone

Comments

@mp911de
Copy link
Member

mp911de commented Mar 28, 2019

Calling AnnotatedElementUtils.getAllAnnotationAttributes(…, "javax.annotation.Nonnull") with version 5.2.0.BUILD-SNAPSHOT for org.springframework.lang.NonNullApi.class and javax.annotation.ParametersAreNonnullByDefault.class annotation types returns null.

Previously (5.1 and earlier), the method returned MultiValueMap containing annotation attributes.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 28, 2019
@jhoeller jhoeller self-assigned this Mar 28, 2019
@jhoeller jhoeller added type: regression A bug that is also a regression in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 28, 2019
@jhoeller jhoeller added this to the 5.2 M1 milestone Mar 28, 2019
@jhoeller
Copy link
Contributor

Aside from this being a regression that's worth fixing: What kind of algorithm is this? Couldn't you simply use the standard reflection API for annotation introspection purposes there? I'm surprised that standard javax annotations are introspected as attribute value maps...

@mp911de
Copy link
Member Author

mp911de commented Mar 28, 2019

In Spring Data we support annotations and meta-annotations that are annotated with JSR305 annotations to discover whether a package, class or method has opted-in for non-nullability. We do not express a limit on meta-annotation nesting, so one can use either directly JSR305 annotations, Spring Framework annotations (that are annotated with JSR305) or further, composed annotations.

That's, why we are using AnnotatedElementUtils. @Nonnull's when attribute expresses non-nullability or allows opting out to express that a particular argument or return value may be null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants