Skip to content

Commit d185918

Browse files
committed
Fix AsynchronousTlsChannelGroup processPendingInterests
Handle when channels are closed with pending operations when processing pending interests. JAVA-3579
1 parent 629195b commit d185918

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,12 @@ private void processPendingInterests() {
442442
RegisteredSocket socket = (RegisteredSocket) key.attachment();
443443
int pending = socket.pendingOps.getAndSet(0);
444444
if (pending != 0) {
445-
key.interestOps(key.interestOps() | pending);
445+
try {
446+
key.interestOps(key.interestOps() | pending);
447+
} catch (CancelledKeyException e) {
448+
// can happen when channels are closed with pending operations
449+
break;
450+
}
446451
}
447452
}
448453
}

0 commit comments

Comments
 (0)