Closed GregDThomas closed 1 month ago
And another option;
expensive()
method is marked as @Nullable
, lombok carried this annotation through to the getter method that it generates, removing the need to mark the field as @Nullable
.I've also just discovered the lombok.extern.findbugs.addSuppressFBWarnings = true
setting which pretty much solves this, so closing the issue.
Describe the bug If you mark a field with a lazy getter as
@Nullable
, the generated code results in the field being marked as Nullable, even though it's not (it's turned in to an AtomicReference). This trips up some static analysis (e.g. spotbugs).To Reproduce
Consider the following lombok code;
This generates:
Because the
cached
field is marked@Nullable
, spotbugs (and possible others) identify the lineObject $value = this.cached.get();
as problematic,Expected behavior I can see two possible solutions to this - no doubt others exists!
@Nullable
annotation from thecached
field, but retains it on thegetCached()
method.@Nullable
to the@Getter
annotation, so that the@Nullable
is only applied to the method not the field.Version info (please complete the following information):