Skip to content

Commit

Permalink
Add javadoc variable descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Plotnikov committed Jul 11, 2023
1 parent 7c3eb22 commit e18d0c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/com/exactpro/th2/FixHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,15 @@ public class FixHandler implements AutoCloseable, IHandler {
private final InetSocketAddress address;
private final MessageLoader messageLoader;

/**
* recoveryLock is used to prevent messages sending while conn providing missed messages to server.
*/
private final ReentrantLock recoveryLock = new ReentrantLock();
/**
* connectivityMaintenanceLock is used to prevent message reordering.
* It is used to make sequence number increment and send() atomic operation.
* Without atomicity, message reordering is possible.
*/
private final ReentrantLock connectivityMaintenanceLock = new ReentrantLock();

private AtomicReference<Future<?>> heartbeatTimer = new AtomicReference<>(CompletableFuture.completedFuture(null));
Expand Down Expand Up @@ -274,8 +282,8 @@ public CompletableFuture<MessageID> send(@NotNull RawMessage rawMessage) {
} catch (Exception e) {
LOGGER.error("Error while sending message.", e);
} finally {
recoveryLock.unlock();
connectivityMaintenanceLock.unlock();
recoveryLock.unlock();
}
return result;
}
Expand Down Expand Up @@ -1047,9 +1055,12 @@ private void cancelFuture(AtomicReference<Future<?>> future) {

private void withMaintenanceLock(Runnable execution) {
try {
connectivityMaintenanceLock.lock();
execution.run();
} catch (Exception e) {
LOGGER.error("Error while handling maintenance lock", e);
} finally {
connectivityMaintenanceLock.unlock();
}
}
}

0 comments on commit e18d0c4

Please sign in to comment.