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

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

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 status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues 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:

  • #20099 Introduce null-safety of Spring Framework API
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 9, 2018

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 type: enhancement in: core 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 status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants