@Override public void subscribe(Subscriber<? super T> s) { Consumer<Runnable> scheduler; try { scheduler = schedulerFactory.call(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(s, e); return; } if (scheduler == null) { EmptySubscription.error( s, new NullPointerException("The schedulerFactory returned a null Function")); return; } if (value == null) { FluxPublishOn.ScheduledEmptySubscriptionEager parent = new FluxPublishOn.ScheduledEmptySubscriptionEager(s, scheduler); s.onSubscribe(parent); scheduler.accept(parent); } else { s.onSubscribe(new FluxPublishOn.ScheduledSubscriptionEagerCancel<>(s, value, scheduler)); } }
@Override public void subscribe(final Subscriber<? super T> subscriber) { try { if (supplier != null) { subscriber.onSubscribe( new PushSubscription<T>(this, subscriber) { @Override public void request(long elements) { try { supplyValue(subscriber); } catch (Throwable throwable) { subscriber.onError(throwable); } } }); } else { subscriber.onComplete(); } } catch (Throwable throwable) { Exceptions.throwIfFatal(throwable); subscriber.onError(throwable); } }
@Override public void subscribe(Subscriber<? super Object> s) { if (log.isDebugEnabled()) { log.debug( "Subscribing inbound receiver [pending: " + "" + inboundEmitter.getPending() + ", done: " + inboundEmitter.done + "]"); } if (inboundEmitter.actual == null) { if (inboundEmitter.done) { if (inboundEmitter.error != null) { Operators.error(s, inboundEmitter.error); return; } else if (inboundEmitter.getPending() == 0) { Operators.complete(s); return; } } inboundEmitter.init(s); s.onSubscribe(inboundEmitter); } else { Operators.error( s, new IllegalStateException("Only one connection receive subscriber allowed.")); } }
@Override public void subscribe(Subscriber<? super Long> s) { PublisherTimerRunnable r = new PublisherTimerRunnable(s, asyncExecutor); s.onSubscribe(r); r.setCancel(asyncExecutor.apply(r)); }
@Override public void onSubscribe(Subscription s) { if (SubscriptionHelper.validateSubscription(this.s, s)) { return; } this.s = s; actual.onSubscribe(s); }
@Override public void subscribe(Subscriber<? super T> s) { if (array.length == 0) { EmptySubscription.complete(s); return; } s.onSubscribe(new FluxArraySubscription<>(s, array)); }
@Override public void onSubscribe(Subscription s) { if (SubscriptionHelper.validateSubscription(this.s, s)) { return; } this.s = s; Subscriber<? super U> actual = this.actual; U b; try { b = bufferSupplier.get(); } catch (Throwable e) { cancelled = true; s.cancel(); EmptySubscription.error(e, actual); return; } if (b == null) { cancelled = true; s.cancel(); EmptySubscription.error(new NullPointerException("The buffer supplied is null"), actual); return; } buffer = b; Publisher<B> boundary; try { boundary = boundarySupplier.get(); } catch (Throwable ex) { cancelled = true; s.cancel(); EmptySubscription.error(ex, actual); return; } if (boundary == null) { cancelled = true; s.cancel(); EmptySubscription.error( new NullPointerException("The boundary publisher supplied is null"), actual); return; } BufferBoundarySubscriber<T, U, B> bs = new BufferBoundarySubscriber<T, U, B>(this); other = bs; actual.onSubscribe(this); if (!cancelled) { s.request(Long.MAX_VALUE); boundary.subscribe(bs); } }
@Override public void onSubscribe(Subscription s) { if (Operators.validate(this.s, s)) { this.s = s; actual.onSubscribe(this); s.request(Long.MAX_VALUE); } }
@Override void subscribe( AbstractRequestBodyPublisher publisher, Subscriber<? super DataBuffer> subscriber) { Objects.requireNonNull(subscriber); if (publisher.changeState(this, NO_DEMAND)) { Subscription subscription = new RequestBodySubscription(publisher); publisher.subscriber = subscriber; subscriber.onSubscribe(subscription); } else { throw new IllegalStateException(toString()); } }
@Override public void subscribe(final Subscriber<? super QueueSignal> subscriber) { try { if (refCount.getAndIncrement() == 0) { this.channel = lapin.createChannel(); } subscriber.onSubscribe(createSubscription(subscriber, null, null)); } catch (Exception e) { refCount.incrementAndGet(); subscriber.onError(e); } }
/** * Common method to take an Iterator as a source of values. * * @param s * @param it */ static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { if (it == null) { EmptySubscription.error(s, new NullPointerException("The iterator is null")); return; } boolean b; try { b = it.hasNext(); } catch (Throwable e) { EmptySubscription.error(s, e); return; } if (!b) { EmptySubscription.complete(s); return; } s.onSubscribe(new PublisherIterableSubscription<>(s, it)); }
@Override public void onSubscribe(final Subscription s) { this.subscription = s; delegate.onSubscribe(this); }
@Override public void subscribe(Subscriber<? super Object> s) { s.onSubscribe(EmptySubscription.INSTANCE); s.onComplete(); }
@Override public void subscribe(Subscriber<? super T> subscriber) { BasicSubcription<T> sub = new BasicSubcription<>(subscriber, createEmitter()); subscriber.onSubscribe(sub); }
@Override public void onSubscribe(Subscription s) { upstream.onSubscribe(s); }