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
Describe the bug
When a class is annotated with @SuperBuilder and a field in there is annotated with @Builder.Default and has a default value and if there is a constructor present, then the field is not initialised when the constructor is called.
To Reproduce
@Data
@SuperBuilder
public class Model {
@Builder.Default
private List<String> list = new ArrayList<>();
public Model() {
}
}
If the class is created with the builder Model.builder().build(), then list is an ArrayList, if the class is created by calling new Model(), then list is null. The latter is unexpected.
If I delombok the class, it works as expected, list is always ArrayList.
If I use @NoArgsConstructor instead of manually adding the constructor like above, it also works as expected.
Expected behavior
When the constructor is called, all fields should be initialised with their default values.
Version info (please complete the following information):
lombok 1.18.34
javac 17.0.12
The text was updated successfully, but these errors were encountered:
Describe the bug
When a class is annotated with
@SuperBuilder
and a field in there is annotated with@Builder.Default
and has a default value and if there is a constructor present, then the field is not initialised when the constructor is called.To Reproduce
If the class is created with the builder
Model.builder().build()
, thenlist
is anArrayList
, if the class is created by callingnew Model()
, thenlist
isnull
. The latter is unexpected.If I delombok the class, it works as expected,
list
is alwaysArrayList
.If I use
@NoArgsConstructor
instead of manually adding the constructor like above, it also works as expected.Expected behavior
When the constructor is called, all fields should be initialised with their default values.
Version info (please complete the following information):
lombok 1.18.34
javac 17.0.12
The text was updated successfully, but these errors were encountered: