Skip to content

kryo-5.7.1

Latest

Choose a tag to compare

@theigl theigl released this 07 Oct 08:57
· 22 commits to master since this release

This is a maintenance release that fixes the serializers for unmodifiable and synchronized collections introduced in 5.7.0.

Highlights

Registration in a fixed order (#1351)

registerSerializers registered the wrapper classes in HashMap order, so their registration IDs depended on the JVM: eg the unmodifiable list had ID 11 on JDK 17 and 13 on JDK 21. Data written on one JVM could be read as a different wrapper type on another. The new register(Kryo) registers the classes, including the navigable wrappers, in a fixed order:

UnmodifiableCollectionSerializers.register(kryo);
SynchronizedCollectionSerializers.register(kryo);

registerSerializers is deprecated and keeps its IDs, so existing data stays readable. See the upgrade notes below before switching.

Navigable and sequenced wrappers (#1351)

addDefaultSerializers of UnmodifiableCollectionSerializers and SynchronizedCollectionSerializers didn't cover the navigable wrappers (eg Collections.unmodifiableNavigableSet) and the Java 21+ unmodifiable sequenced wrappers (eg Collections.unmodifiableSequencedCollection). These were silently read back as a different wrapper type, eg an UnmodifiableNavigableSet as an UnmodifiableSortedSet. They are now serialized correctly. The serialized bytes are unchanged, so 5.7.0 and 5.7.1 can read each other's data.

All changes

  • #1351 Add serializers for navigable and sequenced wrapper collections and register them in a fixed order

The full list of changes can be found here.

Many thanks to all contributors!

Upgrade Notes

For migration from previous major versions please check out the migration guide. We're asking the community to help and contribute this part: please edit the migration wiki page as you encounter any information or issues that might help others.

Behavioral changes

  • If you use registerSerializers, switch to register(Kryo). It registers the 9 wrapper classes of each type in a different order, so their registration IDs change once: data written with registerSerializers can't be read after switching to register. Switch when you don't need to read previously written data that contains these wrappers, or keep registerSerializers until then.
  • register(Kryo) throws an exception if the JDK internals can't be accessed, while the deprecated registerSerializers logged a warning and skipped the registration. addDefaultSerializers still logs a warning.
  • register(Kryo) doesn't register the Java 21+ sequenced wrappers, so that the same classes are registered on all Java versions. After addDefaultSerializers, they can be registered with kryo.register(Class).

Compatibility

  • Serialization compatible
    • Standard IO: Yes
    • Unsafe-based IO: Yes
  • Binary compatible - Yes (Details)
  • Source compatible - Yes (Details)