Skip to content

Commit

Permalink
Cancel the subscription when disposing ChannelOperations
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jul 7, 2020
1 parent 7500c49 commit e7b876e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/reactor/netty/channel/ChannelOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void dispose() {
log.trace(format(channel(), "Disposing ChannelOperation from a channel"),
new Exception("ChannelOperation dispose stack"));
}
OUTBOUND_CLOSE.set(this, Operators.cancelledSubscription());
if (!inbound.isDisposed()) {
inbound.cancel();
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/reactor/netty/http/server/HttpServerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ public void testIssue630() {
}

@Test
@SuppressWarnings("FutureReturnValueIgnored")
public void testExpectErrorWhenConnectionClosed() throws Exception {
SelfSignedCertificate ssc = new SelfSignedCertificate();
SslContext serverCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
Expand All @@ -1142,7 +1143,8 @@ public void testExpectErrorWhenConnectionClosed() throws Exception {
.port(0)
.secure(spec -> spec.sslContext(serverCtx))
.handle((req, res) -> {
res.withConnection(DisposableChannel::dispose);
// "FutureReturnValueIgnored" is suppressed deliberately
res.withConnection(conn -> conn.channel().close());
return res.sendString(Flux.just("OK").hide())
.then()
.doOnError(t -> {
Expand Down

0 comments on commit e7b876e

Please sign in to comment.