Pigsy-Monk opened a new pull request, #4022: URL: https://github.com/apache/fory/pull/4022
## What does this PR do? Fixes #4021 `ClassResolver.getTypeDefRootTypeId` treated unregistered classes handled by a configured `SerializerFactory` as struct-owned (`NAMED_COMPATIBLE_STRUCT=30`) when no `TypeInfo` existed yet, while the writer encoded `NAMED_EXT=32` after lazily resolving the factory serializer. This caused `"TypeDef root kind does not match"` even when both sides ran identical code with no pre-registration. **Fix**: Probe the `SerializerFactory` via `computeIfAbsent` on a `ConcurrentHashMap<Class<?>, Boolean>` cache. When the factory would supply a custom serializer, normalize the root kind to `NAMED_EXT` so reader and writer agree. ## Changes - `ClassResolver.java`: Add `extSerializerFlagCache` + `isCustomSerializedByFactory()` method; insert probe in both the `hasFieldMetadata=true` branch (reader path) and the no-TypeInfo branch (writer path) of `getTypeDefRootTypeId`. - `TypeDefRootKindSymmetricReproTest.java`: Regression test — two identical instances sharing meta contexts, neither pre-registering the factory-serialized class, round-trip a struct that nests a non-collection subclass with a factory custom serializer. ## Performance - `computeIfAbsent` ensures each class is probed at most once; subsequent calls are O(1) `ConcurrentHashMap.get`. - Thread-safe without external locking. - No change to the `SerializerFactory` interface (no breaking API change). ## Test plan - [x] `TypeDefRootKindSymmetricReproTest`: symmetric no-registration round-trip (was `expected=30, actual=32` → now OK) - [x] `TypeDefRootKindSymmetricReproTest`: with-registration variant also passes - [x] 318 existing TypeDef/meta/resolver/serializer tests pass -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
