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-issuemaster opened this issue Nov 9, 2018 · 1 comment

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster 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-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.