Skip to content

Commit bade992

Browse files
HKrausAxonslandelle
authored andcommitted
Immediately close channel when subscribers cancel (#1459)
This commit includes two changes: - More aggressively mark the ResponseFuture as done to avoid threading issues that still read the old state - Directly invoke channel closing, since there is no guarantee of another channelRead occuring (e.g. if the stream was hard closed)
1 parent 58e590f commit bade992

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: client/src/main/java/org/asynchttpclient/netty/handler/StreamedResponsePublisher.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ public StreamedResponsePublisher(EventExecutor executor, ChannelManager channelM
4242
protected void cancelled() {
4343
logger.debug("Subscriber cancelled, ignoring the rest of the body");
4444

45-
// The subscriber cancelled early, we need to drain the remaining elements from the stream
46-
channelManager.drainChannelAndOffer(channel, future);
47-
channel.pipeline().remove(StreamedResponsePublisher.class);
48-
4945
try {
5046
future.done();
5147
} catch (Exception t) {
5248
// Never propagate exception once we know we are done.
5349
logger.debug(t.getMessage(), t);
5450
}
51+
52+
// The subscriber cancelled early - this channel is dead and should be closed.
53+
channelManager.closeChannel(channel);
5554
}
5655

5756
NettyResponseFuture<?> future() {

0 commit comments

Comments
 (0)