@Override public T get(long arg0, TimeUnit arg1) throws InterruptedException, ExecutionException, TimeoutException { try { return delegateFuture.get(arg0, arg1); } catch (CancellationException e) { prepareCancellationException(e); throw e; } }
@Test public void notStartedTest() throws InterruptedException, ExecutionException { SettableListenableFuture<Object> slf = new SettableListenableFuture<>(); CancelDebuggingListenableFuture<Object> debugFuture = new CancelDebuggingListenableFuture<>(slf); assertTrue(debugFuture.cancel(false)); try { debugFuture.get(); fail("Exception should have thrown"); } catch (CancellationException e) { // expected assertNull(e.getCause()); } }
@Test public void withRunningStackTest() throws InterruptedException, ExecutionException { SettableListenableFuture<Object> slf = new SettableListenableFuture<>(); slf.setRunningThread(Thread.currentThread()); CancelDebuggingListenableFuture<Object> debugFuture = new CancelDebuggingListenableFuture<>(slf); assertTrue(debugFuture.cancel(false)); try { debugFuture.get(); fail("Exception should have thrown"); } catch (CancellationException e) { // expected assertNotNull(e.getCause()); assertTrue(e.getCause() instanceof FutureProcessingStack); assertEquals(this.getClass().getName(), e.getCause().getStackTrace()[3].getClassName()); } } }
@Override public T get() throws InterruptedException, ExecutionException { try { return delegateFuture.get(); } catch (CancellationException e) { prepareCancellationException(e); throw e; } }
@Override public T get() throws InterruptedException, ExecutionException { try { return delegateFuture.get(); } catch (CancellationException e) { prepareCancellationException(e); throw e; } }
@Override public T get(long arg0, TimeUnit arg1) throws InterruptedException, ExecutionException, TimeoutException { try { return delegateFuture.get(arg0, arg1); } catch (CancellationException e) { prepareCancellationException(e); throw e; } }