Repository navigation
Fix #908: Resolve nested classes named by schema in AvroTypeIdResolver, not by probing in AvroSchemaHelper - #909
Closed
cowtowncoder wants to merge 1 commit into
Closed
cowtowncoder wants to merge 1 commit into
cowtowncoder wants to merge 1 commit into
Conversation
…dResolver`, not by probing in `AvroSchemaHelper` - `AvroSchemaHelper.getFullName()` no longer probes for (and loads) nested classes; returns plain dotted name. Static name cache removed. - Union resolution on write matches class name against schema name with new `AvroSchemaHelper.typeIdMatches()`, without class loading. - `AvroTypeIdResolver` resolves dotted type ids into nested class names using databind's class lookup (context ClassLoader first, no initialization, subtype validation), with per-resolver cache. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
AvroTypeIdResolver, not by probing in AvroSchemaHelperAvroTypeIdResolver, not by probing in AvroSchemaHelper
Member
Author
|
Not feasible, closing. |
cowtowncoder
deleted the
tatu-claude/2.x/908-avro-nested-class-lookup
branch
November 18, 2026 03:51
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.
Fixes #908.
Problem
AvroSchemaHelper.getFullName(Schema)probed for nested classes (Class.forName()per dot of the schema namespace) to decide betweenpkg.Outer.Innerandpkg.Outer$Inner. It did so with the Avro module's own ClassLoader, while databind loads the resulting type id viaTypeFactory.findClass()(context ClassLoader first), so the two could disagree; results went into a JVM-wide static cache; and classes named by a possibly untrusted schema were loaded when the schema was processed.Change
AvroSchemaHelper.getFullName()no longer probes: returns the plain dotted name (ornamespace$Namefor old-style$namespaces). The static resolver, its cache and the dot / length limits added in Do not initialize class named by Avro schema when resolving its full name #906 are removed from here.AvroWriteContext.resolveUnionIndex()/resolveUnionType()use newAvroSchemaHelper.typeIdMatches(Class, Schema), which compares class name against schema name (accepting$in class name where namespace has.). No class loading, no cache.AvroTypeIdResolverresolves the dotted id into the actual nested class: tries id as given, then replaces dots with$from the right, viaDatabindContext.resolveAndValidateSubType(); so same ClassLoader lookup as databind, no class initialization, and subtype validation before loading. Results (including "no class found") are cached per resolver instance (100 entries), i.e. per mapper configuration. The 32-dot / 1024-char probing limits now live here.AvroReaderFactory(java.util.EnumSet<pkg.Outer.MyEnum>) get names inside<...>resolved too.Compatibility
JsonParser.getTypeId()now exposespkg.Outer.Innerwhere it used to exposepkg.Outer$Innerfor nested classes named by RECORD / ENUM / FIXED schemas.AvroSchemaHelper.getFullName(Schema)/getTypeId(Schema)return the dotted form as well.Tests
SchemaNameClassInitTestrenamed toSchemaFullNameTest, rewritten for non-probing behavior; adds match / mismatch cases fortypeIdMatches().NestedClassTypeId908Test: nested and doubly nested classes,$namespaces,Mapfallback for unknown names, probing limit boundaries.🤖 Generated with Claude Code