@Override public void run() { writeLock.lock(); try { write(); } catch (InterruptedException e) { LOGGER.info("InterruptedException when writing", e); Thread.currentThread().interrupt(); } finally { writeLock.unlock(); } }
@Test public void interrupted() { Iterator<Object> it = Observable.never().blockingLatest().iterator(); Thread.currentThread().interrupt(); try { it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } Thread.interrupted(); }
@Override public void run() { readLock.lock(); try { read(); } catch (InterruptedException e) { LOGGER.info("InterruptedException when reading", e); Thread.currentThread().interrupt(); } finally { readLock.unlock(); } }
@Test public void awaitTerminalEventInterrupt() { final TestSubscriber<Integer> ts = TestSubscriber.create(); ts.onSubscribe(new BooleanSubscription()); Thread.currentThread().interrupt(); ts.awaitTerminalEvent(); assertTrue(Thread.interrupted()); Thread.currentThread().interrupt(); ts.awaitTerminalEvent(5, TimeUnit.SECONDS); assertTrue(Thread.interrupted()); }
@Override public void run() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS);
@Test public void interrupt() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0L); Thread.currentThread().interrupt(); try { Flowable.just(1) .blockingSubscribe(ts); ts.assertFailure(InterruptedException.class); } finally { Thread.interrupted(); // clear interrupted status just in case } }
@Override public void run() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS);
@Override public void run() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS);
@Test(expected = InterruptedException.class) public void getInterrupted() throws Exception { Thread.currentThread().interrupt(); fo.get(); }
@Test public void interruptTestWaitStrategy() { try { Thread.currentThread().interrupt(); TestWaitStrategy.SLEEP_1000MS.run(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interrupt() { Iterator<Object> it = Flowable.never().blockingNext().iterator(); try { Thread.currentThread().interrupt(); it.next(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interrupt() { Iterator<Object> it = Observable.never().blockingNext().iterator(); try { Thread.currentThread().interrupt(); it.next(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Override public void accept(Emitter<Event> s) { s.onNext(randomEvent(type, numInstances)); try { // slow it down somewhat Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); s.onError(e); } } }
@Override public void accept(Emitter<Event> s) { s.onNext(randomEvent(type, numInstances)); try { // slow it down somewhat Thread.sleep(50); } catch (InterruptedException e) { Thread.currentThread().interrupt(); s.onError(e); } } }
@Test public void interruptWait() { BlockingObservableIterator<Integer> it = new BlockingObservableIterator<Integer>(128); try { Thread.currentThread().interrupt(); it.hasNext(); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void awaitDoneTimed() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); Thread.currentThread().interrupt(); try { ts.awaitDone(5, TimeUnit.SECONDS); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void awaitDoneTimed() { TestObserver<Integer> to = new TestObserver<Integer>(); Thread.currentThread().interrupt(); try { to.awaitDone(5, TimeUnit.SECONDS); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test(timeout = 5000) public void blockingFirstTimeout() { BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>(); Thread.currentThread().interrupt(); try { bf.blockingGet(); fail("Should have thrown!"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }
@Test public void interrupt() { TestObserver<Object> to = new TestObserver<Object>(); Thread.currentThread().interrupt(); Observable.never().blockingSubscribe(to); }
@Test(timeout = 5000) public void blockingFirstTimeout2() { BlockingFirstSubscriber<Integer> bf = new BlockingFirstSubscriber<Integer>(); bf.onSubscribe(new BooleanSubscription()); Thread.currentThread().interrupt(); try { bf.blockingGet(); fail("Should have thrown!"); } catch (RuntimeException ex) { assertTrue(ex.toString(), ex.getCause() instanceof InterruptedException); } }