[QFJ-872] toString() Method Breaks Repeating Groups Created: 23/Dec/15  Updated: 23/Dec/15  Resolved: 23/Dec/15

Status: Closed
Project: QuickFIX/J
Component/s: Build
Affects Version/s: 1.6.0
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Mike Starkie Assignee: Christoph John
Resolution: Not a bug Votes: 0
Labels: QuickfixJ
Environment:

OS X 10.11.2
jdk1.8.0_65


Attachments: Java Source File QuickFixGroupTest.java    

 Description   

Given a valid FIX 4.4 Execution Report FIX string containing a repeating group passed as the single argument to the constructor of the Message type, immediately calling the toString() method on the new instance results in the repeating group being mangled.

Below is the output of the sample program which demonstrates the bug. The first message has field 382[NoContraBrokers] in the correct place at the start of ContraGrp. The toString result has field 375[ContraBroker] coming before 382 which is incorrectly placed outside the group.

Fix String before creating Message instance:
8=FIX.4.4|9=173|35=8|34=3|49=BRKR|52=20121105-23:24:42|56=BANZAI|6=0|11=1352157882577|14=0|17=1|20=0|31=0|32=0|37=1|38=10000|39=0|54=1|55=MSFT|150=2|151=0|382=1|375=1|655=2|437=444|438=888|10=111|

Fix String after calling toString() on the new instance of Message:
8=FIX.4.4|9=173|35=8|34=3|49=BRKR|52=20121105-23:24:42|56=BANZAI|6=0|11=1352157882577|14=0|17=1|20=0|31=0|32=0|37=1|38=10000|39=0|54=1|55=MSFT|150=2|151=0|375=1|382=1|437=444|438=888|655=2|10=111|

----------------------- Sample Code -------------------------

package com.globalforge.infix;

import quickfix.InvalidMessage;
import quickfix.Message;

public class QuickFixGroupTest {
static String FIX_44_EXEC_REPORT =
"8=FIX.4.49=17335=834=349=BRKR52=20121105-23:24:4256=BANZAI6=011=135215788257714=017=120=031=032=037=138=1000039=054=155=MSFT150=2151=0382=1375=1655=2437=444438=88810=111";

public static String rs(String ins)

{ return ins.replaceAll("\u0001", "|"); }

public static void main(String[] args) {
System.out.println("before: " + rs(FIX_44_EXEC_REPORT));
try

{ Message quickFixMsg = new Message(FIX_44_EXEC_REPORT); System.out.println("after : " + rs(quickFixMsg.toString())); }

catch (InvalidMessage e)

{ e.printStackTrace(); }

}
}



 Comments   
Comment by Christoph John [ 23/Dec/15 ]

This is no valid FIX4.4 message for several reasons:

  • tag 20/ExecTransType is not defined in FIX4.4.
  • tag 438/ContraTradeTime should contain a timestamp but contains 888

Moreover, the position of the fields in the repeating groups should be the same as defined in the data dictionary (at least up to and including FIX4.4). But I don't remember if this is in line with the spec or a speciality of QF/J.
But apart from that you really need to specify a data dictionary when wanting to parse repeating groups from a String.

After these changes the parsing succeeds.

     System.out.println("before: " + rs(FIX_44_EXEC_REPORT));
        try {
            Message quickFixMsg = new Message();
            final DataDictionary dataDictionary = new DataDictionary("FIX44.xml");
            quickFixMsg.fromString(FIX_44_EXEC_REPORT, dataDictionary, true);
            System.out.println("after : " + rs(quickFixMsg.toString()));
        } catch (InvalidMessage e) {
            e.printStackTrace();
        }
Comment by Christoph John [ 23/Dec/15 ]

Please post to the mailing list before opening a bug. Thanks
https://lists.sourceforge.net/lists/listinfo/quickfixj-users

Generated at Sun May 05 02:29:58 UTC 2024 using JIRA 7.5.2#75007-sha1:9f5725bb824792b3230a5d8716f0c13e296a3cae.