Skip to content

Commit d917045

Browse files
committed
Fix AsynchronousTlsChannelGroup closing
Ensure the registered sockets' callback is called JAVA-3730
1 parent cc5f0f6 commit d917045

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.mongodb.internal.connection.tlschannel.util.Util;
3030

3131
import java.io.IOException;
32+
import java.nio.channels.AsynchronousCloseException;
3233
import java.nio.channels.CancelledKeyException;
3334
import java.nio.channels.ClosedChannelException;
3435
import java.nio.channels.InterruptedByTimeoutException;
@@ -265,6 +266,9 @@ boolean doCancelRead(final RegisteredSocket socket, final ReadOperation op) {
265266
try {
266267
// a null op means cancel any operation
267268
if (op != null && socket.readOperation == op || op == null && socket.readOperation != null) {
269+
if (op == null) {
270+
socket.readOperation.onFailure.accept(new AsynchronousCloseException());
271+
}
268272
socket.readOperation = null;
269273
cancelledReads.increment();
270274
currentReads.decrement();
@@ -282,6 +286,9 @@ boolean doCancelWrite(final RegisteredSocket socket, final WriteOperation op) {
282286
try {
283287
// a null op means cancel any operation
284288
if (op != null && socket.writeOperation == op || op == null && socket.writeOperation != null) {
289+
if (op == null) {
290+
socket.writeOperation.onFailure.accept(new AsynchronousCloseException());
291+
}
285292
socket.writeOperation = null;
286293
cancelledWrites.increment();
287294
currentWrites.decrement();

0 commit comments

Comments
 (0)