You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2026/01/20 17:41:11 UTC
(httpcomponents-core) branch master updated: Bug fix: Handle CancelledKeyException thrown by abort method of the H2 stream
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
The following commit(s) were added to refs/heads/master by this push:
new 6911f14c6 Bug fix: Handle CancelledKeyException thrown by abort method of the H2 stream
6911f14c6 is described below
commit 6911f14c60654262059c5baf18730e6b65a811e5
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Jan 20 18:40:54 2026 +0100
Bug fix: Handle CancelledKeyException thrown by abort method of the H2 stream
---
.../java/org/apache/hc/core5/http2/impl/nio/H2Stream.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2Stream.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2Stream.java
index 2008ab5f9..8d90bb66c 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2Stream.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/H2Stream.java
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.CancelledKeyException;
import java.nio.charset.CharacterCodingException;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -260,11 +261,13 @@ HandlerFactory<AsyncPushConsumer> getPushHandlerFactory() {
boolean abort() {
if (cancelled.compareAndSet(false, true)) {
- channel.requestOutput();
- return true;
- } else {
- return false;
+ try {
+ channel.requestOutput();
+ return true;
+ } catch (final CancelledKeyException ignore) {
+ }
}
+ return false;
}
boolean abortGracefully() throws IOException {