Skip to content

Commit 25af194

Browse files
committed
trying to stop the writer as soon as it's known that there is a communication issue
1 parent dce9624 commit 25af194

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/main/java/io/nats/client/impl/NatsConnection.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,16 +292,7 @@ public void forceReconnect(ForceReconnectOptions options) throws IOException, In
292292
}
293293

294294
void forceReconnectImpl(@NonNull ForceReconnectOptions frOpts) throws InterruptedException {
295-
if (frOpts.getFlushWait() != null) {
296-
try {
297-
flush(frOpts.getFlushWait());
298-
}
299-
catch (TimeoutException e) {
300-
// Ignored. Manual test demonstrates that if the connection is dropped
301-
// in the middle of the flush, the most likely reason for a TimeoutException,
302-
// the socket is closed.
303-
}
304-
}
295+
writer.stopWriting();
305296

306297
closeSocketLock.lock();
307298
try {
@@ -722,7 +713,7 @@ void handleCommunicationIssue(Exception io) {
722713
statusLock.unlock();
723714
}
724715

725-
writer.preventWrite();
716+
writer.stopWriting();
726717

727718
processException(io);
728719
if (currentServer != null) {

src/main/java/io/nats/client/impl/NatsConnectionWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Future<Boolean> stop() {
132132
return this.stopped;
133133
}
134134

135-
void preventWrite() {
135+
void stopWriting() {
136136
allowedToWrite.set(false);
137137
}
138138

0 commit comments

Comments
 (0)