Search before asking
Version
0.17.0
Component(s)
Java, Eclipse Collections
Minimal reproduce step
Tested with Eclipse Collections' UnifiedMap (any non-java.util Map impl should reproduce):
import org.apache.fory.Fory;
import org.apache.fory.config.CompatibleMode;
import org.apache.fory.config.Language;
import org.eclipse.collections.api.map.MutableMap;
import org.eclipse.collections.impl.map.mutable.UnifiedMap;
public class Holder {
public MutableMap<String, String> data = new UnifiedMap<>();
}
Fory fory = Fory.builder()
.withLanguage(Language.JAVA)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.requireClassRegistration(false)
.build();
Holder h = new Holder();
h.data.put("k", "v");
byte[] bytes = fory.serialize(h); // entry is written to the buffer
Holder out = (Holder) fory.deserialize(bytes);
System.out.println(out.data.getClass()); // class ...UnifiedMap
System.out.println(out.data.size()); // 0 ← silent loss
CompatibleMode.SCHEMA_CONSISTENT (with the class registered) → entry survives.
- Field typed as
java.util.LinkedHashMap (still COMPATIBLE) → entry survives.
- Registering a
CustomMapSerializer<UnifiedMap> per the custom-serializers
guide → entry survives.
What did you expect to see?
One of:
- COMPATIBLE-mode generic dispatch routes unknown
Map / Collection implementations through MapSerializer / CollectionSerializer so entries survive without
explicit registration.
- COMPATIBLE-mode throws on encountering a
Map / Collection impl it cannot fully round-trip, so the failure is loud at the boundary.
What did you see instead?
Silent partial deserialization. Empty collection created, no exceptions thrown.
Anything Else?
I think the default silent behavior is probably correct for most types, but for known collection types, the default behavior should probably be to throw to avoid silent corruption. At least that's my default expectation for collection types.
Search before asking
Version
0.17.0
Component(s)
Java, Eclipse Collections
Minimal reproduce step
Tested with Eclipse Collections'
UnifiedMap(any non-java.utilMapimpl should reproduce):CompatibleMode.SCHEMA_CONSISTENT(with the class registered) → entry survives.java.util.LinkedHashMap(still COMPATIBLE) → entry survives.CustomMapSerializer<UnifiedMap>per the custom-serializersguide → entry survives.
What did you expect to see?
One of:
Map/Collectionimplementations throughMapSerializer/CollectionSerializerso entries survive withoutexplicit registration.
Map/Collectionimpl it cannot fully round-trip, so the failure is loud at the boundary.What did you see instead?
Silent partial deserialization. Empty collection created, no exceptions thrown.
Anything Else?
I think the default silent behavior is probably correct for most types, but for known collection types, the default behavior should probably be to throw to avoid silent corruption. At least that's my default expectation for collection types.