@Override public boolean hasNext() { if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("Iterating over a toIterable() / toStream() is blocking, which is not supported in thread " + Thread.currentThread().getName());
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("blockOptional() is blocking, which is not supported in thread " + Thread.currentThread().getName());
@Test public void isInNonBlockingThreadFalse() { assertThat(Thread.currentThread()).isNotInstanceOf(NonBlocking.class); assertThat(Schedulers.isInNonBlockingThread()).as("isInNonBlockingThread").isFalse(); }
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("blockOptional() is blocking, which is not supported in thread " + Thread.currentThread().getName());
/** * Block until the first value arrives and return it, otherwise * return null for an empty source and rethrow any exception. * * @return the first value or null if the source is empty */ @Nullable final T blockingGet() { if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("block()/blockFirst()/blockLast() are blocking, which is not supported in thread " + Thread.currentThread().getName()); } if (getCount() != 0) { try { await(); } catch (InterruptedException ex) { dispose(); throw Exceptions.propagate(ex); } } Throwable e = error; if (e != null) { RuntimeException re = Exceptions.propagate(e); //this is ok, as re is always a new non-singleton instance re.addSuppressed(new Exception("#block terminated with an error")); throw re; } return value; }
@Test public void isInNonBlockingThreadTrue() { new ReactorThreadFactory.NonBlockingThread(() -> assertThat(Schedulers.isInNonBlockingThread()) .as("isInNonBlockingThread") .isFalse(), "isInNonBlockingThreadTrue"); }
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("block()/blockFirst()/blockLast() are blocking, which is not supported in thread " + Thread.currentThread().getName());
@Override public boolean hasNext() { if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("Iterating over a toIterable() / toStream() is blocking, which is not supported in thread " + Thread.currentThread().getName());
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("blockOptional() is blocking, which is not supported in thread " + Thread.currentThread().getName());
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("blockOptional() is blocking, which is not supported in thread " + Thread.currentThread().getName());
/** * Block until the first value arrives and return it, otherwise * return null for an empty source and rethrow any exception. * * @return the first value or null if the source is empty */ @Nullable final T blockingGet() { if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("block()/blockFirst()/blockLast() are blocking, which is not supported in thread " + Thread.currentThread().getName()); } if (getCount() != 0) { try { await(); } catch (InterruptedException ex) { dispose(); throw Exceptions.propagate(ex); } } Throwable e = error; if (e != null) { RuntimeException re = Exceptions.propagate(e); //this is ok, as re is always a new non-singleton instance re.addSuppressed(new Exception("#block terminated with an error")); throw re; } return value; }
if (Schedulers.isInNonBlockingThread()) { throw new IllegalStateException("block()/blockFirst()/blockLast() are blocking, which is not supported in thread " + Thread.currentThread().getName());