Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

beseder1
Copy link
Contributor

@beseder1 beseder1 commented Sep 18, 2025

(fixes: #601)

With the current implementation of the RecordVisitor, Avro schema unions are handled in a non-deterministic way. This can cause deserialization errors when different AvroMapper instances are used for serialization and deserialization.

Specifically, because the subtype ordering is unstable, deserialization may attempt to resolve a serialized object against the wrong subtype, resulting in errors.

This PR makes the ordering deterministic by using an ArrayList instead of a Set, ensuring consistent behavior across serialization and deserialization.

@beseder1 beseder1 force-pushed the fix/601-deterministic-avro-unions branch from 94b2377 to 0fcc23d Compare September 18, 2025 06:25
@cowtowncoder cowtowncoder added the cla-needed PR looks good (although may also require code review), but CLA needed from submitter label Sep 18, 2025
@cowtowncoder
Copy link
Member

Good start! PR much appreciated.
I think we can avoid separate de-duping by checking for existence on-the-fly, but aside from that I think this makes sense.

One process thing: we need CLA (from either https://github.com/FasterXML/jackson/blob/main/contributor-agreement.pdf (individual) or https://github.com/FasterXML/jackson/blob/main/contributor-agreement.pdf (Corporate CLA)). This is only needed once per contributor, one is good for all future contributions.

The usual way is to print, fill & sign, email to cla at fasterxml dot com. Once this is done I can proceed with merging (pending final review etc).

Looking forward to merging this PR (and backporting in 2.19, I think).

Copy link
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cowtowncoder
Copy link
Member

Ok ready to merge once we get CLA!

Thank you again @beseder1 .

@cowtowncoder cowtowncoder added cla-received Marker to denote that there is a CLA for pr and removed cla-needed PR looks good (although may also require code review), but CLA needed from submitter labels Sep 21, 2025
@cowtowncoder
Copy link
Member

CLA received, will now merge

@cowtowncoder cowtowncoder merged commit 1d33114 into FasterXML:2.x Sep 21, 2025
4 checks passed
beseder1 added a commit to beseder1/jackson-dataformats-binary that referenced this pull request Sep 22, 2025
beseder1 added a commit to beseder1/jackson-dataformats-binary that referenced this pull request Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-received Marker to denote that there is a CLA for pr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jackson subtype Avro schema unions are non-deterministic and therefore incompatible with each other
2 participants