diff options
author | Eike Stepper | 2010-10-08 05:48:07 +0000 |
---|---|---|
committer | Eike Stepper | 2010-10-08 05:48:07 +0000 |
commit | beab28175177115896388305b38dea596fa2ff6e (patch) | |
tree | bc52f6ccfc40ce1b3b2004b63a5bc6ba628d9bb0 /plugins | |
parent | a9a2f35cdf0c981bafdd31a830dc714f43be5238 (diff) | |
download | cdo-beab28175177115896388305b38dea596fa2ff6e.tar.gz cdo-beab28175177115896388305b38dea596fa2ff6e.tar.xz cdo-beab28175177115896388305b38dea596fa2ff6e.zip |
[327295] Not-serializeable remote exceptions lead to time out
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327295
Diffstat (limited to 'plugins')
4 files changed, 63 insertions, 4 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java index 1808664e69..517765439f 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/WrappedException.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation */ @@ -22,11 +22,24 @@ public class WrappedException extends RuntimeException super(exception); } + private WrappedException(String message, Exception exception) + { + super(message, exception); + } + public Exception exception() { return (Exception)getCause(); } + /** + * @since 3.1 + */ + public static RuntimeException wrap(Exception exception, String message) + { + return new WrappedException(message, exception); + } + public static RuntimeException wrap(Exception exception) { if (exception instanceof RuntimeException) diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java index 815ce71ab8..8e6ca853ea 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionIndication.java @@ -4,17 +4,22 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Eike Stepper - initial API and implementation */ package org.eclipse.net4j.signal; import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedIOUtil; import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.internal.net4j.bundle.OM; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + /** * @author Eike Stepper */ @@ -43,13 +48,33 @@ class RemoteExceptionIndication extends Indication try { - t = (Throwable)in.readObject(OM.class.getClassLoader()); + t = deserializeThrowable(in.readByteArray()); } catch (Throwable couldNotLoadExceptionClass) { + // Fall through + } + + if (t == null) + { t = new RemoteException(message, responding); } getProtocol().handleRemoteException(correlationID, t, responding); } + + public static Throwable deserializeThrowable(byte[] bytes) + { + try + { + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + DataInputStream dis = new DataInputStream(bais); + return (Throwable)ExtendedIOUtil.readObject(dis, OM.class.getClassLoader()); + } + catch (IOException ex) + { + OM.LOG.error(ex); + return null; + } + } } diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java index ef3cca91f8..d14b5ce6dc 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/RemoteExceptionRequest.java @@ -11,10 +11,14 @@ package org.eclipse.net4j.signal; import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import org.eclipse.net4j.util.io.ExtendedIOUtil; import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.internal.net4j.bundle.OM; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; + /** * @author Eike Stepper */ @@ -52,7 +56,23 @@ class RemoteExceptionRequest extends Request out.writeInt(correlationID); out.writeBoolean(responding); out.writeString(message); - out.writeObject(t); + out.writeByteArray(serializeThrowable(t)); + } + + public static byte[] serializeThrowable(Throwable t) + { + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + DataOutputStream dos = new DataOutputStream(baos); + ExtendedIOUtil.writeObject(dos, t); + return baos.toByteArray(); + } + catch (Exception ex) + { + OM.LOG.error(ex); + return null; + } } public static String getFirstLine(String message) diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java index eb6d2c9f4c..86f7ec07a7 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/Signal.java @@ -135,6 +135,7 @@ public abstract class Signal implements Runnable public final void run() { String threadName = null; + try { if (OM.SET_SIGNAL_THREAD_NAME) |