Example usage for java.io StreamCorruptedException StreamCorruptedException

List of usage examples for java.io StreamCorruptedException StreamCorruptedException

Introduction

In this page you can find the example usage for java.io StreamCorruptedException StreamCorruptedException.

Prototype

public StreamCorruptedException() 

Source Link

Document

Create a StreamCorruptedException and list no reason why thrown.

Usage

From source file:org.apache.ibatis.executor.loader.AbstractSerialStateHolder.java

@SuppressWarnings("unchecked")
protected final Object readResolve() throws ObjectStreamException {
    /* Second run */
    if (this.userBean != null && this.userBeanBytes.length == 0) {
        return this.userBean;
    }// w  w w .ja  v a  2s.c  o  m

    /* First run */
    try (final ObjectInputStream in = new LookAheadObjectInputStream(
            new ByteArrayInputStream(this.userBeanBytes))) {
        this.userBean = in.readObject();
        this.unloadedProperties = (Map<String, ResultLoaderMap.LoadPair>) in.readObject();
        this.objectFactory = (ObjectFactory) in.readObject();
        this.constructorArgTypes = (Class<?>[]) in.readObject();
        this.constructorArgs = (Object[]) in.readObject();
    } catch (final IOException ex) {
        throw (ObjectStreamException) new StreamCorruptedException().initCause(ex);
    } catch (final ClassNotFoundException ex) {
        throw (ObjectStreamException) new InvalidClassException(ex.getLocalizedMessage()).initCause(ex);
    }

    final Map<String, ResultLoaderMap.LoadPair> arrayProps = new HashMap<>(this.unloadedProperties);
    final List<Class<?>> arrayTypes = Arrays.asList(this.constructorArgTypes);
    final List<Object> arrayValues = Arrays.asList(this.constructorArgs);

    return this.createDeserializationProxy(userBean, arrayProps, objectFactory, arrayTypes, arrayValues);
}