From 5f7fa4051836d2989716d50cc056c89d75c3e5d6 Mon Sep 17 00:00:00 2001 From: scottf Date: Fri, 31 May 2024 10:23:59 -0400 Subject: [PATCH] Trying to ensure no blocking close on force reconnect from socket write timeout --- src/main/java/io/nats/client/impl/NatsConnection.java | 5 +---- .../io/nats/client/impl/SocketDataPortWithWriteTimeout.java | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/io/nats/client/impl/NatsConnection.java b/src/main/java/io/nats/client/impl/NatsConnection.java index 18d0f677e..7e67cd316 100644 --- a/src/main/java/io/nats/client/impl/NatsConnection.java +++ b/src/main/java/io/nats/client/impl/NatsConnection.java @@ -284,8 +284,6 @@ public void forceReconnect() throws IOException, InterruptedException { } void forceReconnectImpl() throws IOException, InterruptedException { - NatsConnectionWriter oldWriter = writer; - closeSocketLock.lock(); try { updateStatus(Status.DISCONNECTED); @@ -299,8 +297,7 @@ void forceReconnectImpl() throws IOException, InterruptedException { try { dataPort.close(); } - catch (IOException ignore) { - } + catch (IOException ignore) {} finally { dataPort = null; } diff --git a/src/main/java/io/nats/client/impl/SocketDataPortWithWriteTimeout.java b/src/main/java/io/nats/client/impl/SocketDataPortWithWriteTimeout.java index 855123af9..b2b70c1d4 100644 --- a/src/main/java/io/nats/client/impl/SocketDataPortWithWriteTimeout.java +++ b/src/main/java/io/nats/client/impl/SocketDataPortWithWriteTimeout.java @@ -38,10 +38,6 @@ public void run() { if (System.nanoTime() > writeMustBeDoneBy) { writeWatcherTimer.cancel(); // we don't need to repeat this connection.executeCallback((c, el) -> el.socketWriteTimeout(c)); - try { - out.close(); - } - catch (IOException ignore) {} connection.getExecutor().submit(() -> { try { connection.forceReconnect();