Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SuperBuilder and Builder.Default break constructor behaviour. #3745

Open
aschepp opened this issue Sep 17, 2024 · 1 comment
Open

[BUG] SuperBuilder and Builder.Default break constructor behaviour. #3745

aschepp opened this issue Sep 17, 2024 · 1 comment

Comments

@aschepp
Copy link

aschepp commented Sep 17, 2024

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

@aschepp
Copy link
Author

aschepp commented Sep 17, 2024

Ah, I missed, that this is already covered by #2340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant