Search in sources :

Example 1 with ExceptionReplacingObjectInputStream

use of org.gradle.internal.serialize.ExceptionReplacingObjectInputStream in project gradle by gradle.

the class InProcessWorkerFactory method transferResultFromWorkerClassLoader.

private DefaultWorkResult transferResultFromWorkerClassLoader(Object result) throws IOException, ClassNotFoundException {
    ByteArrayOutputStream resultBytes = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ExceptionReplacingObjectOutputStream(resultBytes);
    try {
        oos.writeObject(result);
    } finally {
        oos.close();
    }
    ObjectInputStream ois = new ExceptionReplacingObjectInputStream(new ByteArrayInputStream(resultBytes.toByteArray()), getClass().getClassLoader());
    return (DefaultWorkResult) ois.readObject();
}
Also used : ExceptionReplacingObjectInputStream(org.gradle.internal.serialize.ExceptionReplacingObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ExceptionReplacingObjectOutputStream(org.gradle.internal.serialize.ExceptionReplacingObjectOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ExceptionReplacingObjectOutputStream(org.gradle.internal.serialize.ExceptionReplacingObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) ClassLoaderObjectInputStream(org.gradle.internal.io.ClassLoaderObjectInputStream) ExceptionReplacingObjectInputStream(org.gradle.internal.serialize.ExceptionReplacingObjectInputStream)

Example 2 with ExceptionReplacingObjectInputStream

use of org.gradle.internal.serialize.ExceptionReplacingObjectInputStream in project gradle by gradle.

the class IsolatedClassloaderWorkerFactory method transferResultFromWorkerClassLoader.

private DefaultWorkResult transferResultFromWorkerClassLoader(Object result) throws IOException, ClassNotFoundException {
    ByteArrayOutputStream resultBytes = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ExceptionReplacingObjectOutputStream(resultBytes);
    try {
        oos.writeObject(result);
    } finally {
        oos.close();
    }
    ObjectInputStream ois = new ExceptionReplacingObjectInputStream(new ByteArrayInputStream(resultBytes.toByteArray()), getClass().getClassLoader());
    return (DefaultWorkResult) ois.readObject();
}
Also used : ExceptionReplacingObjectInputStream(org.gradle.internal.serialize.ExceptionReplacingObjectInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ExceptionReplacingObjectOutputStream(org.gradle.internal.serialize.ExceptionReplacingObjectOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ExceptionReplacingObjectOutputStream(org.gradle.internal.serialize.ExceptionReplacingObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) ClassLoaderObjectInputStream(org.gradle.internal.io.ClassLoaderObjectInputStream) ExceptionReplacingObjectInputStream(org.gradle.internal.serialize.ExceptionReplacingObjectInputStream)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ClassLoaderObjectInputStream (org.gradle.internal.io.ClassLoaderObjectInputStream)2 ExceptionReplacingObjectInputStream (org.gradle.internal.serialize.ExceptionReplacingObjectInputStream)2 ExceptionReplacingObjectOutputStream (org.gradle.internal.serialize.ExceptionReplacingObjectOutputStream)2