Move gap fill logic into handleSequenceReset, revert msg type check
@@ -524,13 +524,9 @@ public class FIXSession implements Closeable {
}
if (msgType.length() == 1 && msgType.asChar() == SequenceReset) {
- FIXValue gapFillFlag = message.findField(GapFillFlag);
-
- if (gapFillFlag == null || gapFillFlag.asChar() != 'Y') {
- handleSequenceReset(message, true);
+ if(handleSequenceReset(message))
return;
}
- }
if (msgSeqNum > rxMsgSeqNum) {
sendResendRequest(rxMsgSeqNum);
@@ -544,7 +540,12 @@ public class FIXSession implements Closeable {
rxMsgSeqNum++;
- switch ((char) msgType.byteAt(0)) {
+ if (msgType.length() != 1) {
+ downstream.message(message);
+ return;
+ }
+
+ switch (msgType.byteAt(0)) {
case Heartbeat:
handleHeartbeat();
break;
@@ -558,7 +559,7 @@ public class FIXSession implements Closeable {
handleReject(message);
break;
case SequenceReset:
- handleSequenceReset(message, false);
+ handleSequenceReset(message);
break;
case Logout:
handleLogout(message);
@@ -621,23 +622,28 @@ public class FIXSession implements Closeable {
statusListener.reject(FIXSession.this, message);
}
- private void handleSequenceReset(FIXMessage message, boolean reset) throws IOException {
+ private boolean handleSequenceReset(FIXMessage message) throws IOException {
FIXValue value = message.findField(NewSeqNo);
if (value == null) {
sendReject(message.getMsgSeqNum(), 1, "NewSeqNo(36) not found");
- return;
+ return true;
}
long newSeqNo = value.asInt();
if (newSeqNo < rxMsgSeqNum) {
sendReject(message.getMsgSeqNum(), 5, "NewSeqNo(36) too low");
- return;
+ return true;
}
rxMsgSeqNum = newSeqNo;
+ FIXValue gapFillFlag = message.findField(GapFillFlag);
+ boolean reset = gapFillFlag == null || gapFillFlag.asChar() != 'Y';
+
if (reset)
statusListener.sequenceReset(FIXSession.this);
+
+ return reset;
}
private void handleLogout(FIXMessage message) throws IOException {
