You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] NullAssignment: False positive when assigning null to a final field in a constructor #6276
If you have a final field that might be null or not, depending on the called constructor or depending on the arguments given to the constructor, you must set it to null explicitly in the constructor.
If you set it at declaration time, you cannot set it to a different value.
So assigning null to a final field in a constructor should not trigger a finding.
This does sometimes work as expected for example when directly assigning null, but if it is done as part of a ternary expression for example, the rule complains.
changed the title [-][java] `NullAssignment` should not report assigning `null` to a `final` field in a constructor[/-][+][java] NullAssignment: False positive when assigning `null` to a `final` field in a constructor[/+]on Dec 19, 2025
Activity
mrclmh commentedon Nov 27, 2025
Extracted example:
mrclmh commentedon Nov 28, 2025
Another ternary problem mentioned here #1050 (comment).
[-][java] `NullAssignment` should not report assigning `null` to a `final` field in a constructor[/-][+][java] NullAssignment: False positive when assigning `null` to a `final` field in a constructor[/+][doc] Update release notes (#6276, #6293)
[java] Fix #6276: NullAssignment should not report assigning null to …
RM-37163: CPD 7.21.0 upgrade (#8)