From bf8b47b328ac05443480d48f794cf84a23e5d3a2 Mon Sep 17 00:00:00 2001 From: Christoph John Date: Fri, 12 Jan 2024 15:32:34 +0100 Subject: [PATCH 01/10] typos and doc comments --- quickfixj-base/src/main/java/quickfix/FixVersions.java | 2 +- quickfixj-base/src/main/java/quickfix/InvalidMessage.java | 4 ++-- quickfixj-base/src/main/java/quickfix/MessageUtils.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/quickfixj-base/src/main/java/quickfix/FixVersions.java b/quickfixj-base/src/main/java/quickfix/FixVersions.java index 209d65baf8..1f71f3432d 100644 --- a/quickfixj-base/src/main/java/quickfix/FixVersions.java +++ b/quickfixj-base/src/main/java/quickfix/FixVersions.java @@ -30,7 +30,7 @@ public interface FixVersions { String BEGINSTRING_FIX44 = "FIX.4.4"; /* - * FIX 5.0+ does not have a begin string. + * FIX 5.0+ does not have a BeginString. */ String FIX50 = "FIX.5.0"; String FIX50SP1 = "FIX.5.0SP1"; diff --git a/quickfixj-base/src/main/java/quickfix/InvalidMessage.java b/quickfixj-base/src/main/java/quickfix/InvalidMessage.java index c15ee2440a..2476c28928 100644 --- a/quickfixj-base/src/main/java/quickfix/InvalidMessage.java +++ b/quickfixj-base/src/main/java/quickfix/InvalidMessage.java @@ -19,8 +19,8 @@ package quickfix; -/* - * An exception when a message is not valid according to the +/** + * Thrown when a message is not valid according to the * basic message validation or the data dictionary. */ public class InvalidMessage extends Exception { diff --git a/quickfixj-base/src/main/java/quickfix/MessageUtils.java b/quickfixj-base/src/main/java/quickfix/MessageUtils.java index fe7a51b038..2c73ac40c9 100644 --- a/quickfixj-base/src/main/java/quickfix/MessageUtils.java +++ b/quickfixj-base/src/main/java/quickfix/MessageUtils.java @@ -208,10 +208,10 @@ public static String getStringField(String messageString, int tag) { }; /** - * Convert an ApplVerID to a "begin string" + * Convert an ApplVerID to a BeginString. * * @param applVerID - * @return the begin string for the specified ApplVerID. + * @return the BeginString for the specified ApplVerID. * @throws QFJException if conversion fails. * @see ApplVerID */ @@ -239,10 +239,10 @@ public static String toBeginString(ApplVerID applVerID) throws QFJException { }; /** - * Convert a begin string to an ApplVerID + * Convert a BeginString to an ApplVerID. * * @param beginString - * @return the ApplVerID for the specified begin string. + * @return the ApplVerID for the specified BeginString. * @throws QFJException if conversion fails. * @see FixVersions */ From 93610daa2def81203b03a90ef9edf65d7115a226 Mon Sep 17 00:00:00 2001 From: Christoph John Date: Wed, 7 Feb 2024 11:04:23 +0100 Subject: [PATCH 02/10] added convenience method isLogonMsgType() --- quickfixj-base/src/main/java/quickfix/MessageUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/quickfixj-base/src/main/java/quickfix/MessageUtils.java b/quickfixj-base/src/main/java/quickfix/MessageUtils.java index 2c73ac40c9..75e7e09d85 100644 --- a/quickfixj-base/src/main/java/quickfix/MessageUtils.java +++ b/quickfixj-base/src/main/java/quickfix/MessageUtils.java @@ -101,6 +101,7 @@ public static Message parse(MessageFactory messageFactory, DataDictionary dataDi * @param messageFactory * @param dataDictionary * @param messageString + * @param validateChecksum * @return the parsed message * @throws InvalidMessage */ @@ -129,6 +130,10 @@ public static boolean isLogon(String message) { return isMessageType(message, MsgType.LOGON); } + public static boolean isLogonMsgType(String msgType) { + return MsgType.LOGON.equals(msgType); + } + private static boolean isMessageType(String message, String msgType) { try { return msgType.equals(getMessageType(message)); From 26935dba100ef4f30dc7f6815ac622c5684d5995 Mon Sep 17 00:00:00 2001 From: Christoph John Date: Wed, 7 Feb 2024 11:43:38 +0100 Subject: [PATCH 03/10] changed to use session dictionary on Logon message - lookup of application dictionary and throwing of QFJException is prevented this way --- .../java/quickfix/MessageSessionUtils.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/quickfixj-core/src/main/java/quickfix/MessageSessionUtils.java b/quickfixj-core/src/main/java/quickfix/MessageSessionUtils.java index a6eec9e3a6..0bdbafdb8a 100644 --- a/quickfixj-core/src/main/java/quickfix/MessageSessionUtils.java +++ b/quickfixj-core/src/main/java/quickfix/MessageSessionUtils.java @@ -36,6 +36,7 @@ public class MessageSessionUtils { public static Message parse(Session session, String messageString) throws InvalidMessage { final String beginString = MessageUtils.getStringField(messageString, BeginString.FIELD); final String msgType = MessageUtils.getMessageType(messageString); + final boolean isLogon = MessageUtils.isLogonMsgType(msgType); final MessageFactory messageFactory = session.getMessageFactory(); final DataDictionaryProvider ddProvider = session.getDataDictionaryProvider(); final ApplVerID applVerID; @@ -44,17 +45,20 @@ public static Message parse(Session session, String messageString) throws Invali final quickfix.Message message; final DataDictionary payloadDictionary; - if (!MessageUtils.isAdminMessage(msgType) || MessageUtils.isLogon(messageString)) { + if (!MessageUtils.isAdminMessage(msgType) || isLogon) { if (FixVersions.BEGINSTRING_FIXT11.equals(beginString)) { - applVerID = getApplVerID(session, messageString); + applVerID = getApplVerID(session, messageString, isLogon); } else { applVerID = MessageUtils.toApplVerID(beginString); } - final DataDictionary applicationDataDictionary = ddProvider == null ? null : ddProvider - .getApplicationDataDictionary(applVerID); - payloadDictionary = MessageUtils.isAdminMessage(msgType) - ? sessionDataDictionary - : applicationDataDictionary; + + if (isLogon) { + payloadDictionary = sessionDataDictionary; + } else { // we got an app message + final DataDictionary applicationDataDictionary = ddProvider == null ? null : ddProvider + .getApplicationDataDictionary(applVerID); + payloadDictionary = applicationDataDictionary; + } } else { applVerID = null; payloadDictionary = sessionDataDictionary; @@ -70,7 +74,7 @@ public static Message parse(Session session, String messageString) throws Invali return message; } - private static ApplVerID getApplVerID(Session session, String messageString) + private static ApplVerID getApplVerID(Session session, String messageString, boolean isLogon) throws InvalidMessage { ApplVerID applVerID = null; @@ -83,7 +87,7 @@ private static ApplVerID getApplVerID(Session session, String messageString) applVerID = session.getTargetDefaultApplicationVersionID(); } - if (applVerID == null && MessageUtils.isLogon(messageString)) { + if (applVerID == null && isLogon) { final String defaultApplVerIdString = MessageUtils.getStringField(messageString, DefaultApplVerID.FIELD); if (defaultApplVerIdString != null) { From cb3d31e038a12519acda1090c0271effdeac518a Mon Sep 17 00:00:00 2001 From: Christoph John Date: Wed, 7 Feb 2024 11:44:29 +0100 Subject: [PATCH 04/10] added acceptance test --- .../server/fixLatest/LogonUnknownDefaultApplVerID.def | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 quickfixj-core/src/test/resources/quickfix/test/acceptance/definitions/server/fixLatest/LogonUnknownDefaultApplVerID.def diff --git a/quickfixj-core/src/test/resources/quickfix/test/acceptance/definitions/server/fixLatest/LogonUnknownDefaultApplVerID.def b/quickfixj-core/src/test/resources/quickfix/test/acceptance/definitions/server/fixLatest/LogonUnknownDefaultApplVerID.def new file mode 100644 index 0000000000..2079acb12d --- /dev/null +++ b/quickfixj-core/src/test/resources/quickfix/test/acceptance/definitions/server/fixLatest/LogonUnknownDefaultApplVerID.def @@ -0,0 +1,7 @@ +# Send Logout on unknown DefaultApplVerID + +iCONNECT +I8=FIXT.1.135=A34=149=TW52=