From 96b72f68d9261a8be273e2b73894178ad3a121d8 Mon Sep 17 00:00:00 2001 From: "denis.plotnikov" Date: Mon, 18 Nov 2024 11:44:26 +0300 Subject: [PATCH] Avoid double logon --- .../java/com/exactpro/th2/FixHandler.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/exactpro/th2/FixHandler.java b/src/main/java/com/exactpro/th2/FixHandler.java index 73d496a..e8b39fb 100644 --- a/src/main/java/com/exactpro/th2/FixHandler.java +++ b/src/main/java/com/exactpro/th2/FixHandler.java @@ -1200,8 +1200,6 @@ private void sendHeartbeatWithTestRequest(String testRequestId, boolean possDup) communicationLock.unlock(); } - } else { - sendLogon(); } } @@ -1229,8 +1227,6 @@ public void sendTestRequestWithPossDup(boolean isPossDup) { //do private } finally { communicationLock.unlock(); } - } else { - sendLogon(); } reconnectRequestTimer = executorService.schedule(this::sendLogon, settings.getReconnectDelay(), TimeUnit.SECONDS); } @@ -1247,8 +1243,6 @@ public void sendLogon() { return; } - activeLogonExchange.set(true); - if(enabled.get()) { String message = String.format("Logon attempt while already logged in: %s - %s", channel.getSessionGroup(), channel.getSessionAlias()); LOGGER.warn(message); @@ -1258,12 +1252,15 @@ public void sendLogon() { StringBuilder logon = buildLogon(props); - LOGGER.info("Send logon - {}", logon); - channel.send(Unpooled.wrappedBuffer(logon.toString().getBytes(StandardCharsets.UTF_8)), - strategy.getState().enrichProperties(props), - null, - SendMode.HANDLE_AND_MANGLE) - .thenAcceptAsync(x -> strategy.getState().addMessageID(x), executorService); + if(!activeLogonExchange.get()) { + activeLogonExchange.set(true); + LOGGER.info("Send logon - {}", logon); + channel.send(Unpooled.wrappedBuffer(logon.toString().getBytes(StandardCharsets.UTF_8)), + strategy.getState().enrichProperties(props), + null, + SendMode.HANDLE_AND_MANGLE) + .thenAcceptAsync(x -> strategy.getState().addMessageID(x), executorService); + } } private StringBuilder buildLogon(Map props) {