Example usage for java.io ObjectStreamException initCause

List of usage examples for java.io ObjectStreamException initCause

Introduction

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

Prototype

public synchronized Throwable initCause(Throwable cause) 

Source Link

Document

Initializes the cause of this throwable to the specified value.

Usage

From source file:org.grouplens.grapht.annotation.AnnotationProxy.java

/**
 * Customized {@code readObject} implementation to ensure the cached type is resolved.
 *
 * @param in The stream./*  w w  w .ja  v a  2  s. c o m*/
 * @throws java.io.ObjectStreamException If there is an error reading the object from the stream.
 */
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws ObjectStreamException {
    try {
        in.defaultReadObject();
        cachedType = (Class<T>) annotationType.resolve();
    } catch (IOException e) {
        ObjectStreamException ex = new StreamCorruptedException("IO exception");
        ex.initCause(e);
        throw ex;
    } catch (ClassNotFoundException e) {
        ObjectStreamException ex = new InvalidObjectException("IO exception");
        ex.initCause(e);
        throw ex;
    }
}