Example usage for java.io StreamCorruptedException toString

List of usage examples for java.io StreamCorruptedException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:de.dal33t.powerfolder.util.ByteSerializer.java

/**
 * Deserialize a byte[] array into an Object.
 * //from  w w w . java2s . com
 * @param base
 *            The byte[] array
 * @param expectCompression
 *            if there is a zip compression expected
 * @return The deserialized object
 * @throws IOException
 *             an I/O Error occured
 * @throws ClassNotFoundException
 *             the class for the Object to be deserialized cannot be found.
 */
public static Object deserializeStatic(byte[] base, boolean expectCompression)
        throws IOException, ClassNotFoundException {
    Object result;
    try {
        result = deserialize0(base, expectCompression);
    } catch (IOException e) {
        try {
            result = deserialize0(base, !expectCompression);
        } catch (StreamCorruptedException e2) {
            LOG.log(Level.WARNING,
                    "While deserializing " + (expectCompression ? "   compressed" : "uncompressed") + ": " + e,
                    e);
            if (!e2.toString().toLowerCase().contains("invalid stream header: 1f8b0800")) {
                LOG.log(Level.WARNING, "While deserializing "
                        + (!expectCompression ? "   compressed" : "uncompressed") + ": " + e2, e2);
            }
            throw e2;
        } catch (InvalidClassException e2) {
            LOG.log(Level.WARNING, "While deserializing: " + e2, e2);
            throw e2;
        }
        if (!(result instanceof Identity)) {
            LOG.warning(
                    "Stream was not as expected ("
                            + (expectCompression ? "compression was expected, but received uncompressed data"
                                    : "no compression was expected, but received compressed data")
                            + ") on " + result);
        }

    }
    return result;
}