Skip to content

Commit 2113293

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 00205cd commit 2113293

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
@@ -367,14 +367,20 @@ private synchronized void onChannelClose(ChannelFuture f) {
367367
message = ERR_CLOSED_BY_SERVER;
368368
event = ConnectionCloseEvent.CLOSE_BY_REMOTE;
369369
}
370-
if (state.get() != State.CONNECTING) {
371-
Exception ex = new ConnectionClosedException(message, f.cause());
370+
371+
final boolean notify = state.get() != State.CONNECTING;
372+
final Exception ex = notify ? new ConnectionClosedException(message, f.cause()) : null;
373+
if (notify) {
372374
failConnectPromise(ex);
373-
fire(event, ex);
374375
}
375-
state.set(State.CLOSED);
376+
376377
channel = null;
377378
connectPromise = null;
379+
state.set(State.CLOSED);
380+
381+
if (notify) {
382+
fire(event, ex);
383+
}
378384
}
379385

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

0 commit comments

Comments
 (0)