private void interruptIfNecessary() { Thread currentReceiveThread = this.currentReceiveThread; if (currentReceiveThread != null && !currentReceiveThread.isInterrupted()) { currentReceiveThread.interrupt(); } }
@Override public void accept(Throwable e) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void run() throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Throwable e) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Throwable e) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Throwable e) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void run() throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Object v) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Object v) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void run() throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Object v) throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void run() throws Exception { interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void run() { assertThat(Thread.currentThread().isInterrupted()).isFalse(); } });
@Override public void run() { terminated.set(shutdownAndAwaitTermination(service, 1L, SECONDS)); interrupted.set(Thread.currentThread().isInterrupted()); } });
@Override public void run() { assertThat(Thread.currentThread().isInterrupted()).isFalse(); } });
@Override public void accept(Object v, Throwable e) throws Exception { assertNotNull(v); assertNull(e); interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@Override public void accept(Object v, Throwable e) throws Exception { assertNull(v); assertNotNull(e); interrupted.set(Thread.currentThread().isInterrupted()); cdl.countDown(); } });
@GwtIncompatible // Thread.interrupt public void testGetUnchecked_interrupted() { Thread.currentThread().interrupt(); try { assertEquals("foo", getUnchecked(immediateFuture("foo"))); assertTrue(Thread.currentThread().isInterrupted()); } finally { Thread.interrupted(); } }
public void testGetCheckedUntimed_interrupted() { SettableFuture<String> future = SettableFuture.create(); Thread.currentThread().interrupt(); try { getChecked(future, TwoArgConstructorException.class); fail(); } catch (TwoArgConstructorException expected) { assertThat(expected).hasCauseThat().isInstanceOf(InterruptedException.class); assertTrue(Thread.currentThread().isInterrupted()); } finally { Thread.interrupted(); } }
public void testNoOpServiceStartStopAndWaitUninterruptible() throws Exception { NoOpService service = new NoOpService(); currentThread().interrupt(); try { service.startAsync().awaitRunning(); assertEquals(State.RUNNING, service.state()); service.stopAsync().awaitTerminated(); assertEquals(State.TERMINATED, service.state()); assertTrue(currentThread().isInterrupted()); } finally { Thread.interrupted(); // clear interrupt for future tests } }