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 2025/09/25 12:17:58 UTC
(httpcomponents-core) branch master updated: Added safeguard for CancelledKeyException to async I/O session #enqueue method
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 d043e5ed6 Added safeguard for CancelledKeyException to async I/O session #enqueue method
d043e5ed6 is described below
commit d043e5ed6fb3467eecd00719f59691569baa4c87
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Thu Sep 25 14:12:46 2025 +0200
Added safeguard for CancelledKeyException to async I/O session #enqueue method
---
.../src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
index b41979900..75ae9a75f 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
@@ -32,6 +32,7 @@
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
+import java.nio.channels.CancelledKeyException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.Deque;
@@ -112,7 +113,11 @@ public void enqueue(final Command command, final Command.Priority priority) {
commandQueue.add(command);
}
if (status.get() == Status.ACTIVE) {
- setEvent(SelectionKey.OP_WRITE);
+ try {
+ setEvent(SelectionKey.OP_WRITE);
+ } catch (final CancelledKeyException ignore) {
+ command.cancel();
+ }
} else {
command.cancel();
}