Skip to content

Commit 5d96deb

Browse files
committed
Bug fix: Handle CancelledKeyException thrown by abort method of the H2 stream
1 parent 15e9de4 commit 5d96deb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio

httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2Stream.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.io.IOException;
3131
import java.nio.ByteBuffer;
32+
import java.nio.channels.CancelledKeyException;
3233
import java.nio.charset.CharacterCodingException;
3334
import java.util.List;
3435
import java.util.concurrent.atomic.AtomicBoolean;
@@ -249,11 +250,13 @@ HandlerFactory<AsyncPushConsumer> getPushHandlerFactory() {
249250

250251
boolean abort() {
251252
if (cancelled.compareAndSet(false, true)) {
252-
channel.requestOutput();
253-
return true;
254-
} else {
255-
return false;
253+
try {
254+
channel.requestOutput();
255+
return true;
256+
} catch (final CancelledKeyException ignore) {
257+
}
256258
}
259+
return false;
257260
}
258261

259262
boolean abortGracefully() throws IOException {

0 commit comments

Comments
 (0)