Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDMap cannot be build out of a message containing two components with a same group name #528

Closed
santiagoribero opened this issue Jun 10, 2019 · 1 comment

Comments

@santiagoribero
Copy link

santiagoribero commented Jun 10, 2019

Example case:

<fix major="5" minor="0">
  <header/>
  <trailer/>
  <messages>
    <message name="AllocationReport" msgtype="AS" msgcat="app">
      <component name="TrdInstrmtLegGrp" required="N"/>
      <component name="InstrmtLegAllocGrp" required="N"/>
    </message>
  </messages>
  <components>
    <component name="TrdInstrmtLegGrp">
      <group name="NoLegs" required="N">
            <field number="654" name="LegRefID" required="N"/>
      </group>
    </component>
    <component name="InstrmtLegAllocGrp">
      <group name="NoLegs" required="N">
            <field number="1400" name="EncryptedPasswordMethod" required="Y"/>
      </group>
    </component>
  </components>
  <fields>
    <field number="555" name="NoLegs" type="NUMINGROUP"/>
    <field number="654" name="LegRefID" type="STRING"/>
    <field number="1400" name="EncryptedPasswordMethod" type="INT"/>
  </fields>
</fix>

As you can see, the message “AllocationReport” contains two components, both containing the group “NoLegs” (555), although the groups have different content.
QuickFix tries to create a DDMap per message, containing (in its “Groups” property) all the groups from all the components of the message.
When it has to create the DDMap for the “AllocationReport” message:

  1. it processes the component “TrdInstrmtLegGrp” and inserts the group “NoLegs” to the dictionary, with key 555.
  2. It processes the component “InstrmtLegAllocGrp” and tries to insert its “NoLegs” group, but the dictionary already contains the key 555, therefore an Exception is thrown.
else if(childNode.Name == "group")
{
    DDField fld = FieldsByName[childNode.Attributes["name"].Value];
    DDGrp grp = new DDGrp();
    XmlAttribute req = childNode.Attributes["required"];
    if (req != null && req.Value == "Y"
    && (componentRequired == null || componentRequired.Value == true))
    {
        ddmap.ReqFields.Add(fld.Tag);
        grp.Required = true;
    }
    if (!ddmap.IsField(fld.Tag))
    {
        ddmap.Fields.Add(fld.Tag, fld);
    }
    grp.NumFld = fld.Tag;
    parseMsgEl(childNode, grp);
    ddmap.Groups.Add(fld.Tag, grp); //########### It fails when the second component is processed ###########
}
@santiagoribero santiagoribero changed the title DataDictionary cannot be build out of an message containing two components with a same group name DDMap cannot be build out of a message containing two components with a same group name Jun 10, 2019
@gbirchmeier
Copy link
Member

gbirchmeier commented Jun 10, 2019

This is a known issue, #495.

Your code diagnosis is a little different than mine, but it all stems from the same flawed design. The original writers simply didn't plan for this to ever happen.

I'm going to close this as dupe, but I'll make a note in the other issue to refer to your code findings here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants