@Test public void badException() { Throwable e = new BadException(); assertSame(e, new CompositeException(e).getCause().getCause()); assertSame(e, new CompositeException(new RuntimeException(e)).getCause().getCause().getCause()); }
@Override public synchronized Throwable getCause() { if (cause == null) { CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain(); Set<Throwable> seenCauses = new HashSet<Throwable>(); Throwable chain = localCause; for (Throwable e : exceptions) { if (seenCauses.contains(e)) { continue; } seenCauses.add(e); List<Throwable> listOfCauses = getListOfCauses(e); for (Throwable child : listOfCauses) { if (seenCauses.contains(child)) { e = new RuntimeException("Duplicate found in causal chain so cropping to prevent loop ..."); continue; } seenCauses.add(child); } try { chain.initCause(e); } catch (Throwable t) { } chain = getRootCause(chain); } cause = localCause; } return cause; }
CompositeException extends RuntimeException { @Override public synchronized Throwable getCause() { if (cause == null) { CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain(); Set<Throwable> seenCauses = new HashSet<Throwable>(); Throwable chain = localCause; for (Throwable e : exceptions) { if (seenCauses.contains(e)) { continue; } seenCauses.add(e); List<Throwable> listOfCauses = getListOfCauses(e); for (Throwable child : listOfCauses) { if (seenCauses.contains(child)) { e = new RuntimeException("Duplicate found in causal chain so cropping to prevent loop ..."); continue; } seenCauses.add(child); } try { chain.initCause(e); } catch (Throwable t) { } chain = getRootCause(chain); } cause = localCause; } return cause; } }
CompositeException extends RuntimeException { @Override public synchronized Throwable getCause() { if (cause == null) { CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain(); Set<Throwable> seenCauses = new HashSet<Throwable>(); Throwable chain = localCause; for (Throwable e : exceptions) { if (seenCauses.contains(e)) { continue; } seenCauses.add(e); List<Throwable> listOfCauses = getListOfCauses(e); for (Throwable child : listOfCauses) { if (seenCauses.contains(child)) { e = new RuntimeException("Duplicate found in causal chain so cropping to prevent loop ..."); continue; } seenCauses.add(child); } try { chain.initCause(e); } catch (Throwable t) { } chain = getRootCause(chain); } cause = localCause; } return cause; } CompositeException(Throwable... exceptions);  CompositeException(Iterable<? extends Throwable> errors); }
CompositeException extends RuntimeException { @Override public synchronized Throwable getCause() { if (cause == null) { CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain(); Set<Throwable> seenCauses = new HashSet<Throwable>(); Throwable chain = localCause; for (Throwable e : exceptions) { if (seenCauses.contains(e)) { continue; } seenCauses.add(e); List<Throwable> listOfCauses = getListOfCauses(e); for (Throwable child : listOfCauses) { if (seenCauses.contains(child)) { e = new RuntimeException("Duplicate found in causal chain so cropping to prevent loop ..."); continue; } seenCauses.add(child); } try { chain.initCause(e); } catch (Throwable t) { } chain = getRootCause(chain); } cause = localCause; } return cause; } CompositeException(Throwable... exceptions);  CompositeException(Iterable<? extends Throwable> errors); List<Throwable> getExceptions(); @Override String getMessage(); @Override synchronized Throwable getCause(); @Override void printStackTrace(); @Override void printStackTrace(PrintStream s); @Override void printStackTrace(PrintWriter s); int size(); }
CompositeException extends RuntimeException { @Override public synchronized Throwable getCause() { if (cause == null) { CompositeExceptionCausalChain localCause = new CompositeExceptionCausalChain(); Set<Throwable> seenCauses = new HashSet<Throwable>(); Throwable chain = localCause; for (Throwable e : exceptions) { if (seenCauses.contains(e)) { continue; } seenCauses.add(e); List<Throwable> listOfCauses = getListOfCauses(e); for (Throwable child : listOfCauses) { if (seenCauses.contains(child)) { e = new RuntimeException("Duplicate found in causal chain so cropping to prevent loop ..."); continue; } seenCauses.add(child); } try { chain.initCause(e); } catch (Throwable t) { } chain = getRootCause(chain); } cause = localCause; } return cause; } CompositeException(Throwable... exceptions);  CompositeException(Iterable<? extends Throwable> errors); List<Throwable> getExceptions(); @Override String getMessage(); @Override synchronized Throwable getCause(); @Override void printStackTrace(); @Override void printStackTrace(PrintStream s); @Override void printStackTrace(PrintWriter s); int size();  }