You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "chaokunyang (via GitHub)" <gi...@apache.org> on 2026/09/22 14:15:58 UTC
[PR] fix(json): retain properties without defaults under NON_DEFAULT [fory]
chaokunyang opened a new pull request, #4078:
URL: https://github.com/apache/fory/pull/4078
## Why?
`NON_DEFAULT` rejected properties without defaults, so a Scala model such as `@JsonInclude(NON_DEFAULT) case class Request(id: String, retries: Int = 3)` could not serialize without an `ALWAYS` override on `id`. Java parameterized creators and Kotlin required parameters had the same problem.
## What does this PR do?
Keep properties without defaults in the output under both class-level `@JsonInclude(NON_DEFAULT)` and field-level `@JsonProperty(include = NON_DEFAULT)`, including null, zero, false and empty values. Apply the decision in the existing codec initialization path; per-write omission and generated code remain unchanged.
- Scala keeps properties without a supported compiler default method and continues comparing declared defaults using the current object's actual dependencies.
- Java keeps authorized properties when the selected read path has no no-argument reference constructor. An unrelated no-argument constructor does not replace the selected creator.
- Kotlin keeps required constructor properties and uninitialized `lateinit` properties in the write schema. Defaulted properties still require a legal all-default reference construction path; required arguments are never fabricated.
- Preserve failures from selected default methods, unavailable dependencies, and reference construction. Keep global `NON_DEFAULT` rejection.
- Update annotation Javadocs and JSON guides, and cover Mixin and generated/non-generated paths.
## Validation
OpenJDK 25.0.3:
- Java: `JsonInclusionTest` (30 tests) and `JsonTypeProcessorTest` (73 tests), including actual compilation and use of generated codecs.
- Scala: `ScalaJsonSuite`, 78 tests each on Scala 2.13.18 and 3.3.8.
- Kotlin: `KotlinDefaultArgumentsTest` (4 tests), including String/UTF-8 and compact/pretty output with codegen on/off.
- Kotlin KSP: `R8RulesWriterTest` and `ProcessorResourceTest` (10 tests). Existing retention paths need no production changes. These resource tests are not Android/native-image end-to-end validation.
- Java Spotless/Checkstyle, Kotlin Spotless, Markdown formatting and `git diff --check` passed.
No GraalVM or benchmarks were run.
## Does this PR introduce any user-facing change?
Properties without defaults no longer cause an error under class-level or field-level `NON_DEFAULT`; their values are serialized. No public API additions or binary protocol changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(json): retain properties without defaults under NON_DEFAULT [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang merged PR #4078:
URL: https://github.com/apache/fory/pull/4078
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org