From 09da10cc6c585995f4623793aa2b2f6a38b5284d Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Thu, 13 Dec 2018 23:02:30 +0200 Subject: [PATCH] Propagate the cancel signal to the downstream Issue: SPR-17609 --- .../http/server/reactive/ChannelSendOperator.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java index 2e5b3fce980..731f22b24f5 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ChannelSendOperator.java @@ -338,6 +338,9 @@ public class ChannelSendOperator extends Mono implements Scannable { private final WriteBarrier writeBarrier; + @Nullable + private Subscription subscription; + public WriteCompletionBarrier(CoreSubscriber subscriber, WriteBarrier writeBarrier) { this.completionSubscriber = subscriber; @@ -357,6 +360,7 @@ public class ChannelSendOperator extends Mono implements Scannable { @Override public void onSubscribe(Subscription subscription) { + this.subscription = subscription; subscription.request(Long.MAX_VALUE); } @@ -388,6 +392,10 @@ public class ChannelSendOperator extends Mono implements Scannable { @Override public void cancel() { this.writeBarrier.cancel(); + Subscription subscription = this.subscription; + if (subscription != null) { + subscription.cancel(); + } } }