@Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return true; }
@Override public Future<V> await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
@Override public VoidChannelPromise await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
@Override public boolean await(long timeoutMillis) throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return true; }
@Override public VoidChannelPromise await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
@Override public boolean await(long timeoutMillis) throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return true; }
@Override public Future<V> await() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } return this; }
public InterruptException(String message) { super(message, new InterruptedException()); Thread.currentThread().interrupt(); }
private void maybeThrowInterruptException() { if (Thread.interrupted()) { throw new InterruptException(new InterruptedException()); } }
@Override public void waitUntil(long deadlineMilliseconds) throws InterruptedException { while (deadlineMilliseconds >= System.currentTimeMillis()) { if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } } }
public static void checkInterrupted() { if (Thread.interrupted()) { throw new QueryInterruptedException(new InterruptedException()); } }
@Override public void waitUntil(long deadlineMilliseconds) throws InterruptedException { while (deadlineMilliseconds >= System.currentTimeMillis()) { Thread.yield(); if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } } }
@Override public SegmentsAndMetadata get() throws InterruptedException { throw new InterruptedException("Interrupt test while pushing segments"); } };
private ViewJob getNext() throws InterruptedException { synchronized(reloadQueue) { // reload operations might eat InterruptException, // so check the status every so often while(reloadQueue.isEmpty() && !terminating()) reloadQueue.wait(60*1000); if(terminating()) throw new InterruptedException(); // terminate now ViewJob job = reloadQueue.iterator().next(); reloadQueue.remove(job); return job; } }
/** * Waits for the guard to be satisfied. Waits at most the given time, and may be interrupted. May * be called only by a thread currently occupying this monitor. * * @return whether the guard is now satisfied * @throws InterruptedException if interrupted while waiting */ @SuppressWarnings("GoodTime") // should accept a java.time.Duration public boolean waitFor(Guard guard, long time, TimeUnit unit) throws InterruptedException { final long timeoutNanos = toSafeNanos(time, unit); if (!((guard.monitor == this) & lock.isHeldByCurrentThread())) { throw new IllegalMonitorStateException(); } if (guard.isSatisfied()) { return true; } if (Thread.interrupted()) { throw new InterruptedException(); } return awaitNanos(guard, timeoutNanos, true); }
public void testAddDelayedShutdownHook_interrupted() throws InterruptedException { TestApplication application = new TestApplication(); ExecutorService service = mock(ExecutorService.class); application.addDelayedShutdownHook(service, 2, TimeUnit.SECONDS); when(service.awaitTermination(2, TimeUnit.SECONDS)).thenThrow(new InterruptedException()); application.shutdown(); verify(service).shutdown(); }
@Test public void testThrow() { final Exception expected = new InterruptedException(); try { ExceptionUtils.rethrow(expected); fail("Exception not thrown"); } catch (final Exception actual) { assertSame(expected, actual); } }
public void testBulkLoadInterruptedException() { Exception e = new InterruptedException(); CacheLoader<Object, Object> loader = exceptionLoader(e); LoadingCache<Object, Object> cache = CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader)); CacheStats stats = cache.stats(); assertEquals(0, stats.missCount()); assertEquals(0, stats.loadSuccessCount()); assertEquals(0, stats.loadExceptionCount()); assertEquals(0, stats.hitCount()); try { cache.getAll(asList(new Object())); fail(); } catch (ExecutionException expected) { assertThat(expected).hasCauseThat().isSameAs(e); } assertTrue(currentThread().interrupted()); stats = cache.stats(); assertEquals(1, stats.missCount()); assertEquals(0, stats.loadSuccessCount()); assertEquals(1, stats.loadExceptionCount()); assertEquals(0, stats.hitCount()); }
@Test public void matchingRollbackOnApplied() throws Throwable { assertEquals(0, this.txManager.begun); InterruptedException test = new InterruptedException(); try { new JtaAnnotationPublicAnnotatedMember().echo(test); fail("Should have thrown an exception"); } catch (Throwable throwable) { assertEquals("wrong exception", test, throwable); } assertEquals(1, this.txManager.rollbacks); assertEquals(0, this.txManager.commits); }
@Test public void isBug() { assertFalse(RxJavaPlugins.isBug(new RuntimeException())); assertFalse(RxJavaPlugins.isBug(new IOException())); assertFalse(RxJavaPlugins.isBug(new InterruptedException())); assertFalse(RxJavaPlugins.isBug(new InterruptedIOException())); assertTrue(RxJavaPlugins.isBug(new NullPointerException())); assertTrue(RxJavaPlugins.isBug(new IllegalArgumentException())); assertTrue(RxJavaPlugins.isBug(new IllegalStateException())); assertTrue(RxJavaPlugins.isBug(new MissingBackpressureException())); assertTrue(RxJavaPlugins.isBug(new ProtocolViolationException(""))); assertTrue(RxJavaPlugins.isBug(new UndeliverableException(new TestException()))); assertTrue(RxJavaPlugins.isBug(new CompositeException(new TestException()))); assertTrue(RxJavaPlugins.isBug(new OnErrorNotImplementedException(new TestException()))); } }