Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions quickfixj-core/src/main/java/quickfix/MessageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,31 +129,34 @@ public static Message parse(MessageFactory messageFactory, DataDictionary dataDi
public static Message parse(Session session, String messageString) throws InvalidMessage {
final String beginString = getStringField(messageString, BeginString.FIELD);
final String msgType = getMessageType(messageString);

ApplVerID applVerID;

if (FixVersions.BEGINSTRING_FIXT11.equals(beginString)) {
applVerID = getApplVerID(session, messageString);
} else {
applVerID = toApplVerID(beginString);
}

final MessageFactory messageFactory = session.getMessageFactory();

final DataDictionaryProvider ddProvider = session.getDataDictionaryProvider();
final ApplVerID applVerID;
final DataDictionary sessionDataDictionary = ddProvider == null ? null : ddProvider
.getSessionDataDictionary(beginString);
final DataDictionary applicationDataDictionary = ddProvider == null ? null : ddProvider
.getApplicationDataDictionary(applVerID);

final quickfix.Message message = messageFactory.create(beginString, applVerID, msgType);
final DataDictionary payloadDictionary = MessageUtils.isAdminMessage(msgType)
? sessionDataDictionary
: applicationDataDictionary;
final quickfix.Message message;
final DataDictionary payloadDictionary;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added somefinal here to make it look similar to the surrounding code.


if (!isAdminMessage(msgType) || isLogon(messageString)) {
if (FixVersions.BEGINSTRING_FIXT11.equals(beginString)) {
applVerID = getApplVerID(session, messageString);
} else {
applVerID = toApplVerID(beginString);
}
final DataDictionary applicationDataDictionary = ddProvider == null ? null : ddProvider
.getApplicationDataDictionary(applVerID);
payloadDictionary = MessageUtils.isAdminMessage(msgType)
? sessionDataDictionary
: applicationDataDictionary;
} else {
applVerID = null;
payloadDictionary = sessionDataDictionary;
}

final boolean doValidation = payloadDictionary != null;
final boolean validateChecksum = session.isValidateChecksum();

message = messageFactory.create(beginString, applVerID, msgType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pulled this out of the if-else-block since the assignment was the same.

message.parse(messageString, sessionDataDictionary, payloadDictionary, doValidation,
validateChecksum);

Expand Down
14 changes: 14 additions & 0 deletions quickfixj-core/src/test/java/quickfix/MessageUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ public void testParseFixtLogon() throws Exception {
assertThat(message, is(quickfix.fixt11.Logon.class));
}

public void testParseFixtLogout() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
stub(mockSession.getDataDictionaryProvider()).toReturn(mockDataDictionaryProvider);
stub(mockSession.getMessageFactory()).toReturn(new DefaultMessageFactory());

quickfix.fixt11.Logout logout = new quickfix.fixt11.Logout();

Message message = MessageUtils.parse(mockSession, logout.toString());

assertThat(message, is(notNullValue()));
assertThat(message, is(quickfix.fixt11.Logout.class));
}

public void testParseFix50() throws Exception {
Session mockSession = mock(Session.class);
DataDictionaryProvider mockDataDictionaryProvider = mock(DataDictionaryProvider.class);
Expand Down