@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { switch (state) { case NO_SUBSCRIBER: noSubscriberError = cause; state = NO_SUBSCRIBER_ERROR; cleanup(); break; case BUFFERING: case DEMANDING: case IDLE: case DRAINING: state = DONE; cleanup(); subscriber.onError(cause); break; } }
private void receivedCancel() { switch (state) { case BUFFERING: case DEMANDING: case IDLE: cancelled(); case DRAINING: state = DONE; break; } cleanup(); subscriber = null; }
private void illegalDemand() { cleanup(); subscriber.onError(new IllegalArgumentException("Request for 0 or negative elements in violation of Section 3.9 of the Reactive Streams specification")); ctx.close(); state = DONE; }
private void provideSubscriber(Subscriber<? super T> subscriber) { this.subscriber = subscriber; switch (state) { case NO_SUBSCRIBER_OR_CONTEXT: state = NO_CONTEXT; break; case NO_SUBSCRIBER: if (buffer.isEmpty()) { state = IDLE; } else { state = BUFFERING; } subscriber.onSubscribe(new ChannelSubscription()); break; case DRAINING: subscriber.onSubscribe(new ChannelSubscription()); break; case NO_SUBSCRIBER_ERROR: cleanup(); state = DONE; subscriber.onSubscribe(new ChannelSubscription()); subscriber.onError(noSubscriberError); break; } }