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

Support @Nullable annotations as indicators for optional injection points [SPR-15028] #19595

Closed
spring-projects-issues opened this issue Dec 18, 2016 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 18, 2016

Juergen Hoeller opened SPR-15028 and commented

Along the lines of Guice (https://github.com/google/guice/wiki/UseNullable), we can easily detect @Nullable annotations and automatically mark method parameters and dependency descriptors as optional, i.e. not required, injecting null instead of throwing an UnsatisfiedDependencyException. This is particularly useful with JSR-330's @Inject where not @Autowired-style required attribute is available at the injection annotation level, as an alternative to using Java 8's java.util.Optional (which Spring supports for a while already). This also nicely goes along with our support for nullable type declarations in Kotlin.


Issue Links:

Referenced from: commits 12aa14d

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: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants