Interface Serializer

All Known Implementing Classes:
JDKSerializer, KryoSerializer

public interface Serializer
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Releases any thread-local resources held by this serializer for the current thread.
    byte[]
    serialize(Object object)
    Serialize method
    unserialize(byte[] bytes)
    Unserialize method
  • Method Details

    • serialize

      byte[] serialize(Object object)
      Serialize method
      Parameters:
      object -
      Returns:
      serialized bytes
    • unserialize

      Object unserialize(byte[] bytes)
      Unserialize method
      Parameters:
      bytes -
      Returns:
      unserialized object
    • reset

      default void reset()
      Releases any thread-local resources held by this serializer for the current thread. Implementations that use ThreadLocal storage (e.g. KryoSerializer) should override this method to call ThreadLocal.remove() and prevent ClassLoader pinning / Metaspace leaks in web-container environments (Tomcat, etc.) where container threads are reused across redeployments. Callers (e.g. a ServletContextListener) should invoke this method for each thread that has used the serializer before the application is stopped.