@Override public void accept(Throwable t1) { t1.printStackTrace(); } },
@Override public void accept(Throwable t1) { t1.printStackTrace(); } },
@Override public void onError(Throwable e) { e.printStackTrace(); latch.countDown(); }
@Override public void onError(Throwable e) { e.printStackTrace(); latch.countDown(); }
@Override public void onError(Throwable e) { e.printStackTrace(); latch.countDown(); }
@Override public void onError(Throwable e) { count.decrementAndGet(); e.printStackTrace(); } });
@Override public void onError(Throwable e) { e.printStackTrace(); latch.countDown(); }
@Override public void onError(Throwable e) { System.out.println("error: " + e.getMessage()); e.printStackTrace(); }
@Override public void onError(Throwable e) { error.set(e); System.out.println("error"); e.printStackTrace(); }
@Override public void onError(Throwable e) { error.set(e); System.out.println("error"); e.printStackTrace(); }
private static void waitOnThreads(Future<?>... futures) { for (Future<?> f : futures) { try { f.get(20, TimeUnit.SECONDS); } catch (Throwable e) { System.err.println("Failed while waiting on future."); e.printStackTrace(); } } }
@Override public void onError(Throwable e) { error.set(e); System.out.println("error"); e.printStackTrace(); }
private static void waitOnThreads(Future<?>... futures) { for (Future<?> f : futures) { try { f.get(20, TimeUnit.SECONDS); } catch (Throwable e) { System.err.println("Failed while waiting on future."); e.printStackTrace(); } } }
@Override public void onError(Throwable e) { error.set(e); System.out.println("error"); e.printStackTrace(); latch.countDown(); }
public static String stackTraceAsString(Throwable e) { StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); return sw.toString(); }
/** * This hijacks the Throwable.printStackTrace() output and puts it in a string, where we can look for * "CIRCULAR REFERENCE" (a String added by Throwable.printEnclosedStackTrace) */ private static void assertNoCircularReferences(Throwable ex) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(baos); ex.printStackTrace(printStream); assertFalse(baos.toString().contains("CIRCULAR REFERENCE")); }
@Test(timeout = 1000) public void testCompositeExceptionFromParentThenChild() { CompositeException cex = new CompositeException(ex1, ex2); System.err.println("----------------------------- print composite stacktrace"); cex.printStackTrace(); assertEquals(2, cex.getExceptions().size()); assertNoCircularReferences(cex); assertNotNull(getRootCause(cex)); System.err.println("----------------------------- print cause stacktrace"); cex.getCause().printStackTrace(); }
@Test(timeout = 1000) public void testCompositeExceptionFromChildThenParent() { CompositeException cex = new CompositeException(ex2, ex1); System.err.println("----------------------------- print composite stacktrace"); cex.printStackTrace(); assertEquals(2, cex.getExceptions().size()); assertNoCircularReferences(cex); assertNotNull(getRootCause(cex)); System.err.println("----------------------------- print cause stacktrace"); cex.getCause().printStackTrace(); }
@Test(timeout = 1000) public void testCompositeExceptionFromChildAndComposite() { CompositeException cex = new CompositeException(ex1, getNewCompositeExceptionWithEx123()); System.err.println("----------------------------- print composite stacktrace"); cex.printStackTrace(); assertEquals(3, cex.getExceptions().size()); assertNoCircularReferences(cex); assertNotNull(getRootCause(cex)); System.err.println("----------------------------- print cause stacktrace"); cex.getCause().printStackTrace(); }
@Test(timeout = 1000) public void testCompositeExceptionFromCompositeAndChild() { CompositeException cex = new CompositeException(getNewCompositeExceptionWithEx123(), ex1); System.err.println("----------------------------- print composite stacktrace"); cex.printStackTrace(); assertEquals(3, cex.getExceptions().size()); assertNoCircularReferences(cex); assertNotNull(getRootCause(cex)); System.err.println("----------------------------- print cause stacktrace"); cex.getCause().printStackTrace(); }