@Override
    public void onNext(ByteBuffer buffer) {
      super.onNext(buffer);

      if (this.responseChannel == null) {
        this.responseChannel = exchange.getResponseChannel();
      }

      this.writing.incrementAndGet();
      try {
        int c;
        do {
          c = this.responseChannel.write(buffer);
        } while (buffer.hasRemaining() && c > 0);

        if (buffer.hasRemaining()) {
          this.writing.incrementAndGet();
          enqueue(buffer);
          this.responseChannel.getWriteSetter().set(this);
          this.responseChannel.resumeWrites();
        } else {
          this.subscription.request(1);
        }

      } catch (IOException ex) {
        onError(ex);
      } finally {
        this.writing.decrementAndGet();
        if (this.closing.get()) {
          closeIfDone();
        }
      }
    }
 @Override
 public void onComplete() {
   super.onComplete();
   if (this.responseChannel != null) {
     this.closing.set(true);
     closeIfDone();
   }
 }
 @Override
 public void onError(Throwable ex) {
   super.onError(ex);
   logger.error("ResponseBodySubscriber error", ex);
   if (!exchange.isResponseStarted() && exchange.getStatusCode() < 500) {
     exchange.setStatusCode(500);
   }
 }
Esempio n. 4
0
 @Override
 public void onSubscribe(Subscription s) {
   super.onSubscribe(s);
   subscription = s;
   long r = pendingRequests;
   if (r > 0) {
     subscription.request(r);
   }
 }
Esempio n. 5
0
 @Override
 public BaseProcessor<IN, OUT> start() {
   super.start();
   return this;
 }
 @Override
 public void onSubscribe(Subscription subscription) {
   super.onSubscribe(subscription);
   this.subscription = subscription;
   this.subscription.request(1);
 }
Esempio n. 7
0
 @Override
 public void onComplete() {
   super.onComplete();
   broadcastComplete();
 }
Esempio n. 8
0
 @Override
 public void onError(Throwable t) {
   super.onError(t);
   broadcastError(t);
 }
Esempio n. 9
0
 @Override
 public void onNext(T t) {
   super.onNext(t);
   BackpressureUtils.getAndSub(REQUESTED, FallbackAction.this, 1L);
   doFallbackNext(t);
 }