Skip to content

feat(java): capture and forward extra fields in compatible mode#3858

Closed
Tatenda-k wants to merge 1 commit into
apache:mainfrom
Tatenda-k:main
Closed

feat(java): capture and forward extra fields in compatible mode#3858
Tatenda-k wants to merge 1 commit into
apache:mainfrom
Tatenda-k:main

Conversation

@Tatenda-k

@Tatenda-k Tatenda-k commented Jul 15, 2026

Copy link
Copy Markdown

What does this PR do?

This PR adds support for preserving unknown fields during compatible serialization using ForyExtraFields.

A class opts in by declaring a ForyExtraFields sink. Fields present in the remote schema but not in the local schema are captured in the sink.

Captured fields are replayed using the original remote TypeDef, allowing them to be preserved across compatible serialization round trips involving different schemas.

Replay serializers are cached by (class, TypeDef), allowing a local class to replay ForyExtraFields captured from multiple remote schemas.

Tests cover both enabled and disabled reference tracking, as well as both codegen=true and codegen=false.

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary 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.

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes
  • If yes, I included the standardized AI Usage Disclosure block below.
  • If yes, I can explain and defend all important changes without AI help.
  • If yes, I reviewed AI-assisted code changes line by line before submission.
  • If yes, I completed line-by-line self-review first and fixed issues before requesting AI review.
  • If yes, I ran two fresh AI review agents on the current PR diff or current HEAD after the latest code changes: one Fory-guided reviewer using AGENTS.md and .agents/ci-and-pr.md, and one independent general reviewer in a separate clean-context review session that was not pointed to .agents/ci-and-pr.md or any copied Fory-specific review checklist. If the independent reviewer's tooling auto-loaded AGENTS.md, it followed the independent-review carve-out there.
  • If yes, I addressed all AI review comments and repeated the review loop until both ai reviewers reported no further actionable comments.
  • If yes, I attached screenshot evidence or equivalent persisted links 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.
  • If yes, I ran adequate human verification and recorded evidence (checks run locally or in CI, pass/fail summary, and confirmation I reviewed results).
  • If yes, I added/updated tests and specs where required.
  • If yes, I validated protocol/performance impacts with evidence when applicable.
  • If yes, I verified licensing and provenance compliance.

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Add ForyExtraFields sink, an opt-in mechanism for preserving unmatched
remote fields during compatible-mode deserialization and replaying them
on re-serialization.
Covers both the  interpreter and generated codepaths,
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

Successfully merging this pull request may close these issues.

[Java] Deserialization optimization, instead of discarding fields, puts non-existent fields into a specified field.

1 participant