@Test public void testDeserializationUnknownChildException() throws Exception { ClassLoader cl = new URLClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", null, cl); obj.initCause(new SQLException("something bad happended")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(new ExceptionHolder(new BadException2(obj, "I have foreign exception embedded in me"))); oos.flush(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); ExceptionHolder holder = (ExceptionHolder)ois.readObject(); Throwable e = holder.getException(); assertTrue(e instanceof BadException2); assertEquals("Remote org.teiid.client.util.TestExceptionHolder$BadException2: I have foreign exception embedded in me", e.getMessage()); e = e.getCause(); assertTrue(e instanceof TeiidRuntimeException); e = e.getCause(); assertTrue(e instanceof SQLException); assertEquals("Remote java.sql.SQLException: something bad happended", e.getMessage()); }
public Throwable getException() { return exception; }
ExceptionHolder implements Externalizable { public Throwable getException() { return exception; } }
ExceptionHolder implements Externalizable { public Throwable getException() { return exception; } ExceptionHolder();  ExceptionHolder(Throwable exception);  ExceptionHolder(Throwable exception, boolean nested); }
ExceptionHolder implements Externalizable { public Throwable getException() { return exception; } ExceptionHolder();  ExceptionHolder(Throwable exception);  ExceptionHolder(Throwable exception, boolean nested); @Override void readExternal(ObjectInput in); @Override void writeExternal(ObjectOutput out); Throwable getException(); static List<ExceptionHolder> toExceptionHolders(List<? extends Throwable> throwables); static List<Throwable> toThrowables(List<ExceptionHolder> exceptionHolders); }
ExceptionHolder implements Externalizable { public Throwable getException() { return exception; } ExceptionHolder();  ExceptionHolder(Throwable exception);  ExceptionHolder(Throwable exception, boolean nested); @Override void readExternal(ObjectInput in); @Override void writeExternal(ObjectOutput out); Throwable getException(); static List<ExceptionHolder> toExceptionHolders(List<? extends Throwable> throwables); static List<Throwable> toThrowables(List<ExceptionHolder> exceptionHolders);  }