Class JavaSerializationCopier

java.lang.Object
com.github.benmanes.caffeine.jcache.copy.AbstractCopier<byte[]>
com.github.benmanes.caffeine.jcache.copy.JavaSerializationCopier
All Implemented Interfaces:
Copier

@NullMarked public class JavaSerializationCopier extends AbstractCopier<byte[]>
A strategy that uses Java serialization if a fast path approach is not applicable.

Beware that Java serialization is slow, can be insecure, and is provided due to being required by JSR-107. In practice, it is recommended that a higher performance alternative is used, which is provided by numerous external libraries. If serialization must be used then consider supplying an ObjectInputFilter or enabling Serialization Filtering to restrict the classes that can be deserialized.

  • Constructor Details

  • Method Details

    • serialize

      protected byte[] serialize(Object object)
      Description copied from class: AbstractCopier
      Serializes the object.
      Specified by:
      serialize in class AbstractCopier<byte[]>
      Parameters:
      object - the object to serialize
      Returns:
      the serialized bytes
    • deserialize

      protected Object deserialize(byte[] data, ClassLoader classLoader)
      Description copied from class: AbstractCopier
      Deserializes the data using the provided classloader.
      Specified by:
      deserialize in class AbstractCopier<byte[]>
      Parameters:
      data - the serialized bytes
      classLoader - the classloader to create the instance with
      Returns:
      the deserialized object