Skip to content

Commit 84c3c83

Browse files
committed
Ignore CancelledKeyException in AsynchronousTlsChannelGroup#loop
In testing we've observed that SelectionKey#interestOps can sometimes throw a CancelledKeyException when channels are being closed forcefully by the server in response to operations with failpoints set on them. CancelledKeyException is already ingored elsewhere in AsynchronousTlsChannelGroup, and it seems it has to also be ignore in the processPendingInterests method. JAVA-4024
1 parent a75be45 commit 84c3c83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

driver-core/src/main/com/mongodb/internal/connection/tlschannel/async/AsynchronousTlsChannelGroup.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,11 @@ private void processPendingInterests() {
436436
RegisteredSocket socket = (RegisteredSocket) key.attachment();
437437
int pending = socket.pendingOps.getAndSet(0);
438438
if (pending != 0) {
439-
key.interestOps(key.interestOps() | pending);
439+
try {
440+
key.interestOps(key.interestOps() | pending);
441+
} catch (CancelledKeyException e) {
442+
// can happen when channels are closed with pending operations
443+
}
440444
}
441445
}
442446
}

0 commit comments

Comments
 (0)