Skip to content

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

Closed

Description

@spring-projects-issues

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

Activity

  1. added
    type: enhancement
    in: core
    on Jan 11, 2019
  2. added this to the 5.0 M4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions