Skip to content

Commit 9dd9e49

Browse files
committed
fix(core): notifying clients about the closure
Fixed the notification sent to clients regarding connection closure. It is now guaranteed that clients are notified of the closure only after the connection has transitioned to the CLOSED state.
1 parent c205961 commit 9dd9e49

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎tarantool-core/src/main/java/io/tarantool/core/connection/ConnectionImpl.java‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,20 @@ private synchronized void onChannelClose(ChannelFuture f) {
371371
message = ERR_CLOSED_BY_SERVER;
372372
event = ConnectionCloseEvent.CLOSE_BY_REMOTE;
373373
}
374-
if (state.get() != State.CONNECTING) {
375-
Exception ex = new ConnectionClosedException(message, f.cause());
374+
375+
final boolean notify = state.get() != State.CONNECTING;
376+
final Exception ex = notify ? new ConnectionClosedException(message, f.cause()) : null;
377+
if (notify) {
376378
failConnectPromise(ex);
377-
fire(event, ex);
378379
}
379-
state.set(State.CLOSED);
380+
380381
channel = null;
381382
connectPromise = null;
383+
state.set(State.CLOSED);
384+
385+
if (notify) {
386+
fire(event, ex);
387+
}
382388
}
383389

384390
private <T> void completePromise(CompletableFuture<T> promise, T result) {

0 commit comments

Comments
 (0)