Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Plotnikov committed Nov 29, 2023
1 parent ac4ff4a commit 2aa3468
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/main/java/com/exactpro/th2/FixHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ private Map<String, String> fakeRetransmissionOutgoingProcessor(ByteBuf message,
onOutgoingUpdateTag(message, metadata);

FixField sendingTime = requireNonNull(findField(message, SENDING_TIME_TAG));
strategy.getState().addMissedMessageToCacheIfCondition(msgSeqNum.get(), Unpooled.copiedBuffer(message), x -> true);
strategy.getState().addMissedMessageToCacheIfCondition(msgSeqNum.get(), message.copy(), x -> true);

sendingTime
.insertNext(ORIG_SENDING_TIME_TAG, sendingTime.getValue())
Expand Down Expand Up @@ -2077,8 +2077,13 @@ private void recoveryFromState(Integer beginSeqNo, Integer endSeqNo) {
new HashMap<String, String>(), null, SendMode.MANGLE
).thenAcceptAsync(x -> strategy.getState().addMessageID(x), executorService);
} else {
setTime(missedMessage);
setPossDup(missedMessage);
FixField possDup = findField(missedMessage, POSS_DUP_TAG);
if(possDup == null || !Objects.equals(possDup.getValue(), IS_POSS_DUP)) {
setPossDup(missedMessage);
setTime(missedMessage);
} else {
updateSendingTime(missedMessage);
}
updateLength(missedMessage);
updateChecksum(missedMessage);

Expand Down Expand Up @@ -2145,6 +2150,11 @@ private void setPossDup(ByteBuf buf) {
sendingTime.insertNext(POSS_DUP_TAG, IS_POSS_DUP);
}

private void updateSendingTime(ByteBuf buf) {
FixField sendingTime = Objects.requireNonNull(findField(buf, SENDING_TIME_TAG));
sendingTime.setValue(getTime());
}

private void setTime(ByteBuf buf) {
FixField sendingTime = findField(buf, SENDING_TIME_TAG);
FixField seqNum = requireNonNull(findField(buf, MSG_SEQ_NUM_TAG), "SeqNum field was null.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class StrategyState(val config: RuleConfiguration? = null,
}
}

fun getMissedMessage(sequence: Long): ByteBuf? = lock.read { missedMessagesCache[sequence] }
fun getMissedMessage(sequence: Long): ByteBuf? = lock.read { missedMessagesCache.remove(sequence) }

fun updateCacheAndRunOnCondition(message: ByteBuf, condition: (Int) -> Boolean, function: (ByteBuf) -> Unit) = lock.write {
batchMessageCache.addComponent(true, message.copy().asExpandable())
Expand Down

0 comments on commit 2aa3468

Please sign in to comment.