Class SerializationUtils.ClassLoaderAwareObjectInputStream

java.lang.Object
java.io.InputStream
java.io.ObjectInputStream
org.apache.commons.lang3.SerializationUtils.ClassLoaderAwareObjectInputStream
All Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable
Enclosing class:
SerializationUtils

static class SerializationUtils.ClassLoaderAwareObjectInputStream extends ObjectInputStream

Custom specialization of the standard JDK ObjectInputStream that uses a custom ClassLoader to resolve a class. If the specified ClassLoader is not able to resolve the class, the context classloader of the current thread will be used. This way, the standard deserialization work also in web-application containers and application servers, no matter in which of the ClassLoader the particular class that encapsulates serialization/deserialization lives.

For more in-depth information about the problem for which this class here is a workaround, see the JIRA issue LANG-626.

  • Field Details

    • primitiveTypes

      private static final Map<String,Class<?>> primitiveTypes
    • classLoader

      private final ClassLoader classLoader
  • Constructor Details

    • ClassLoaderAwareObjectInputStream

      ClassLoaderAwareObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException
      Constructor.
      Parameters:
      in - The InputStream.
      classLoader - classloader to use
      Throws:
      IOException - if an I/O error occurs while reading stream header.
      See Also:
  • Method Details