Skip to content

Nullability consistency for getter and setter #29573

Closed as not planned
Closed as not planned
@jlous

Description

@jlous

Where possible, setter-getter-pairs where the getter is @Nullable should also tag the setter argument as @Nullable.

Mismatched nullabillity breaks property-style access from Kotlin. This must be so, because treating such a pair as a consistent property that is either nullable or not would result in unexpected NPEs during either writing or reading respectively

There are of course cases where setting to null should be disallowed, but usually (e.g. SimpleMailMessage) the setters simply assign to a backing variable, and the consequences of doing so with null are no different than leaving it uninitialised, and should be explicitly allowed.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions