Skip to content

Commit

Permalink
Avoid double logon
Browse files Browse the repository at this point in the history
  • Loading branch information
denis.plotnikov committed Nov 18, 2024
1 parent 730cce2 commit 96b72f6
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/main/java/com/exactpro/th2/FixHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,6 @@ private void sendHeartbeatWithTestRequest(String testRequestId, boolean possDup)
communicationLock.unlock();
}

} else {
sendLogon();
}
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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<String, String> props) {
Expand Down

0 comments on commit 96b72f6

Please sign in to comment.