fix(java): honor record field encoding in generated decode#3626
Merged
Conversation
chaokunyang
approved these changes
Apr 28, 2026
Collaborator
chaokunyang
left a comment
There was a problem hiding this comment.
LGTM, thanks for the fix. New release wil come in next week
This was referenced May 13, 2026
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.
Why?
Java record deserialization in generated compatible-mode serializers used type-level primitive decoding for nullable record fields. For boxed primitive record components this could make the generated writer and reader choose different encodings, corrupting values during round trip.
This fixes the shared root cause for #3622 and #3624.
What does this PR do?
ThreadSafeForycross-pool reproducer for a boxedLongrecord with number/string compression.LongandIntegercomponents matching Java record with boxed primitive components corrupts fields when codegen is enabled #3622.Locale.ROOT.Related issues
withNumberCompressed(true)silently corrupts boxedLongfields when serialize and deserialize go through differentThreadSafeForyPoolinstances #3624AI Contribution Checklist
yesyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.yes, my PR description includes the requiredai_reviewsummary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.Contributor checklist for substantial AI assistance:
yesyes, I included the standardizedAI Usage Disclosureblock below.yes, I can explain and defend all important changes without AI help.yes, I reviewed AI-assisted code changes line by line before submission.yes, I completed line-by-line self-review first and fixed issues before requesting AI review.yes, I ran two fresh AI review agents on the current PR diff or current HEAD after the latest code changes: one using.claude/skills/fory-code-review/SKILL.mdand one without that skill.yes, I addressed all AI review comments and repeated the review loop until both AI reviewers reported no further actionable comments.yes, I attached screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes in this PR body.yes, I ran adequate local verification and recorded evidence (checks run locally or in CI, pass/fail summary, and confirmation I reviewed results).yes, I added/updated tests and specs where required.yes, I validated protocol/performance impacts with evidence when applicable.yes, I verified licensing and provenance compliance.AI Usage Disclosure
mvn -pl fory-latest-jdk-tests -am -Dtest=org.apache.fory.integration_tests.RecordSerializersTest#testCompatibleCodegenBoxedPrimitiveRecordRoundTrip -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl fory-latest-jdk-tests -am -Dtest=org.apache.fory.integration_tests.RecordSerializersTest -Dsurefire.failIfNoSpecifiedTests=false testENABLE_FORY_DEBUG_OUTPUT=1 mvn -pl fory-latest-jdk-tests -am -Dtest=org.apache.fory.integration_tests.RecordSerializersTest,org.apache.fory.integration_tests.RecordXlangTest -Dsurefire.failIfNoSpecifiedTests=false testENABLE_FORY_DEBUG_OUTPUT=1 mvn -pl fory-core -am -Dtest=org.apache.fory.serializer.CodegenSerializerTest,org.apache.fory.builder.ObjectCodecBuilderTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl fory-core,fory-latest-jdk-tests -DskipTests spotless:check checkstyle:check(Maven reported cached metadata warnings forglobal-maven-virtual, but the build completed successfully.)Does this PR introduce any user-facing change?
Benchmark
N/A. This is a targeted Java generated-code bug fix; no benchmark was run.