[BUG][JAVA][Spring] 22604 - With NonNull field we can't have an empty constructor #22605
+70
−1,478
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #22604
PR checklist
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)As suggested for Java Spring:
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)
This current implementation breaks a lot of existing code, at least by removing the default constructor use by objectmapper. I think people that stay with object mapper will probably not be able to use JSpecify (or at least remove it from generated code).
As mentioned in the issue #22604 we may prefer to introduce a new parameter.
Summary by cubic
Stop generating no-arg constructors for Java Spring models when OPENAPI_NULLABLE is enabled, preventing empty constructors on models with non-nullable fields. Fixes #22604.
Written for commit 2a23228. Summary will update on new commits.