Skip to content

[Question] [Java] When the registration IDs are inconsistent, deserialization errors are difficult to debug #2818

@moooonk

Description

@moooonk

Question

I have a system that needs to persist many types of caches to Redis. fory.registeris automatically called during Spring container initialization to register various data classes. Yesterday, I discovered that during system iteration, previously persisted data started causing runtime dynamic type conversion errors. After investigation, I found that data marked as Class A in Redis was being deserialized into Class B objects. The deserialization process didn’t throw any errors—it only failed later during runtime when a generic type cast was enforced.
While I understand that this is due to setting CompatibleMode.COMPATIBLE, which allows field inconsistencies during deserialization, in this case the entire class is inconsistent. After a day of step-by-step debugging, I identified the root cause: the order of automatic registration by the container changed, causing a shift in the class information index and leading to incorrect deserialization results.
Currently, if Fory registration is disabled, a log suggests enabling it. However, the requirement that registration order must remain consistent to avoid serious errors is only mentioned in the API comments of the fory.registerfunction. Could this order-sensitive behavior be highlighted more prominently? Alternatively, is there a solution to make the system compatible with out-of-order registration? In a rapidly iterating large-scale system, maintaining the order of serialized classes or planning IDs for serializable classes is quite cumbersome.
Hi @chaokunyang, hope you can give some advice

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions