[QFJ-536] Checksum patch Created: 28/Jun/10  Updated: 15/Nov/12  Resolved: 20/May/11

Status: Closed
Project: QuickFIX/J
Component/s: Engine
Affects Version/s: 1.4.0
Fix Version/s: 1.5.1

Type: Bug Priority: Major
Reporter: SSE Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

All



 Description   

The getGroups has the side effect of modifying i.e creating the empty group inside the message beeing read (with NoXXX field set to 0). The message serialization and checksum/length calculation inside quickfixj are not consistently treated for NoXXX=0 fields
(i.e: the checksum/length calculation uses the NoXXX=0 field and serialization ignores it).

Fixed: checksum/length calculation in QuickFIX/J for groups having NoXXX=0, in case that the library and getGroups+forwarding is used in a public call.

int calculateLength() {
int result = 0;
int length = 0;
for (Iterator<Field<?>> iter = fields.values().iterator(); iter.hasNext() {
Field<?> field = iter.next();
if (field.getField() == BeginString.FIELD || field.getField() == BodyLength.FIELD

field.getField() == CheckSum.FIELD isGroupField(field.getField())) { continue; }
length = field.getLength();
result += length;
}

Iterator<Map.Entry<Integer, List<Group>>> iterator = groups.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, List<Group>> entry = iterator.next();
List<Group> groupList = entry.getValue();
if (groupList.size() > 0) { // ******* ADDED *******
IntField groupField = new IntField(((Integer) entry.getKey()).intValue());
groupField.setValue(groupList.size());
length = groupField.getLength();
result += length;
for (int i = 0; i < groupList.size(); i++) { Group group = (Group) groupList.get(i); length = group.calculateLength(); result += length; }
}
}

return result;

}

int calculateTotal() {

int result = 0;
for (Iterator<Field<?>> iter = fields.values().iterator(); iter.hasNext() {
Field<?> field = (Field<?>) iter.next();
if (field.getField() == CheckSum.FIELD || isGroupField(field.getField())) { continue; }

result += field.getTotal();
}

Iterator<Map.Entry<Integer, List<Group>>> iterator = groups.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Integer, List<Group>> entry = iterator.next();
List<Group> groupList = entry.getValue();
if (groupList.size() > 0) { // ******* ADDED *******
IntField groupField = new IntField(((Integer) entry.getKey()).intValue());
groupField.setValue(groupList.size());
result += groupField.getTotal();
for (int i = 0; i < groupList.size(); i++)

{ Group group = (Group) groupList.get(i); result += group.calculateTotal(); }

}
}

return result;
}

(Internal reference: IC_57786)



 Comments   
Comment by Steve Bate [ 20/Mar/11 ]

These changes introduced a bug since the calculateString method was not also changed. It was possible to have a message string with a tag=0 but the length of the message is zero. This was causing unit and acceptance tests to fail. Zero length groups are now not serialized into message strings as of SVN rev #1002. However, I'm not sure this is what we really want. The QuickFIX C++ project expects zero length groups to be serialized so, assuming they had a good reason for implementing that behavior, we may be causing some subtle problem with these changes.

Generated at Sat Apr 27 06:54:00 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.