Skip to content

*Utils.find### to return Optional [SPR-17484] #22016

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

Closed
spring-projects-issues opened this issue Nov 9, 2018 · 1 comment
Closed

*Utils.find### to return Optional [SPR-17484] #22016

spring-projects-issues opened this issue Nov 9, 2018 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 9, 2018

László Stahorszki opened SPR-17484 and commented

With the release of Optional in Java 8, I think it would be appropriate for methods, like AnnotationUtils.findAnnotation() to return Optional<T>, so that we don't need additional checking parts if an annotation in this instance exists or not


Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This has been considered but rejected due to the impact: either widespread binary compatibility breakages through changing the return type, or overloaded methods with Optional return types in many places. Also, Kotlin does not specifically support Optional, so it's a bit cumbersome to work with such methods there.

Since we have a nullability story with a non-null-by-default policy and @Nullable annotations in 5.x, we at least provide a formal definition for such null-returning cases now.

@spring-projects-issues spring-projects-issues added status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
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) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants