Repository navigation
[java] Add missing @Nullable with useJspecify for additionalProperties, equals and toIndentedString - #25586
Merged
wing328 merged 2 commits intoNov 10, 2026
Conversation
…s, equals and toIndentedString With useJspecify the model packages are @NullMarked, but the restclient, webclient, resttemplate, native and microprofile templates left several nullable values unannotated: - the additionalProperties map field and getAdditionalProperties(), which stay null until the first putAdditionalProperty call - getAdditionalProperty(String), which returns null for a missing key (a qualified type gets the annotation on its simple name) - the parameter of equals(Object) and toIndentedString(Object), which both handle null Refs OpenAPITools#25536
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 30 files
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
Sekator778
approved these changes
Nov 8, 2026
Sekator778
left a comment
Contributor
There was a problem hiding this comment.
Built the head on JDK 17, ran JavaClientCodegenTest, and compiled clients of all five libraries with useJspecify, including array, map and enum values. For #25536, not this PR: equals(Object) and toIndentedString(Object) are still unannotated in single_request_parameter.mustache (webclient, restclient) and native AbstractOpenApiSchema.mustache.
Member
|
thanks for the PR also cc @jpfinne |
Contributor
Seems good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Partially addresses #25536.
With
useJspecify, model packages are@NullMarked, but the restclient, webclient, resttemplate, native and microprofile templates left these nullable values without@Nullable:additionalPropertiesmap field andgetAdditionalProperties(), which staynulluntil the firstputAdditionalPropertycallgetAdditionalProperty(String), which returnsnullfor a missing key. A qualified type gets the annotation on its simple name (java.time.@Nullable Instant), through the existingjSpecifyNullable/jSpecifyDatatypelambdas.equals(Object)andtoIndentedString(Object), which both handlenullNothing changes without
useJspecify. Not covered here: nullability of the map's values, and the JavaSpring templates.Tests:
JavaClientCodegenTest#testJspecifyNullableAdditionalPropertiesAndObjectParameterscovers all 5 libraries and fails without the template change.JavaClientCodegenTest#testNullableAdditionalPropertiesOnlyWithJspecify.JavaClientCodegenTest,JavaModelTestandJavaMicroprofileServerCodegenTestpass (397 tests).PR checklist
useJspecify(bin/configs/java-*-jspecify*.yaml), which are the only samples these templates affect. The other jspecify configs (spring-boot-4-*,jaxrs-spec-quarkus-jspecify) use other generators whose templates aren't changed here. No generator options changed, so the generator docs are unaffected.Summary by cubic
Adds missing
@Nullableannotations to the restclient, webclient, resttemplate, native, and microprofile Java client templates whenuseJspecifyis enabled, since@NullMarkedpackages would otherwise treat these nullable values as non-null.additionalPropertiesmap field andgetAdditionalProperties(), which staynulluntil the firstputAdditionalPropertycall.getAdditionalProperty(String), which returnsnullfor a missing key; qualified types get the annotation on their simple name (for example,java.time.@Nullable Instant).equals(Object)andtoIndentedString(Object)parameters, which both handlenull.useJspecify.Written for commit 78be673. Summary will update on new commits.