QuickFIX/J
  1. QuickFIX/J
  2. QFJ-201

Potential null pointer in DataDictionary.isMsgField

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.2.1
    • Component/s: Metadata/Specs
    • Labels:
      None

      Description

      isMsgField uses single & after a null check - since & doesn't short circuit it throws null pointer if fields is null.

      Change from:

          public boolean isMsgField(String msgType, int field) {
              Set fields = (Set) messageFields.get(msgType);
              return fields != null & fields.contains(new Integer(field));
          }

      to

          public boolean isMsgField(String msgType, int field) {
              Set fields = (Set) messageFields.get(msgType);
              return fields != null && fields.contains(new Integer(field));
          }


      Unit test - add the following to DataDictionaryTest.testDictionary()

              assertFalse(dd.isMsgField("UNKNOWN_TYPE", 1));


        Activity

        Hide
        Toli Kuznets added a comment -

        Great catch, Brad!
        fixed in rev 684

        Show
        Toli Kuznets added a comment - Great catch, Brad! fixed in rev 684
        Hide
        Brad Harvey added a comment -

        Credit for the catch goes to IntelliJ IDEA's code analysis

        Show
        Brad Harvey added a comment - Credit for the catch goes to IntelliJ IDEA's code analysis

          People

          • Assignee:
            Steve Bate
            Reporter:
            Brad Harvey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development