Uploaded image for project: 'QuickFIX/J'
  1. QuickFIX/J
  2. QFJ-89

sessionID added to global Sessions after first log message - which causes NPE if JdbcLog is misconfigured

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Default
    • Resolution: Fixed
    • Affects Version/s: 1.0.4
    • Fix Version/s: 1.1.0
    • Component/s: Engine
    • Labels:
      None

      Description

      This is an obscure bug that only surfaces when you have the JdbcLogger configured, but it actually can't connect to the DB to log the message.

      Stack Trace:
      1:13:18,038 ERROR [main] quickfix.CompositeLog (CompositeLog.java:53) - null, c
      ontinuing
      java.lang.NullPointerException
      at quickfix.LogUtil.logThrowable(LogUtil.java:54)
      at quickfix.JdbcLog.insert(JdbcLog.java:70)
      at quickfix.JdbcLog.onEvent(JdbcLog.java:43)
      at quickfix.CompositeLog.onEvent(CompositeLog.java:79)
      at quickfix.Session.<init>(Session.java:195)
      at

      Turns out the new session is only added to the list of sessions after this log message is printed so moving line 200 above line 195 fixes the issue and displays the right error message (which is the cause for the Log failure)

      Here's the patch as well:

      svn diff Session.java
      Index: Session.java
      ===================================================================
      — Session.java (revision 536)
      +++ Session.java (working copy)
      @@ -227,12 +227,12 @@
      state.setInitiator(heartbeatInterval != 0);
      state.setMessageStore(messageStoreFactory.create(sessionID));
      this.messageFactory = messageFactory;
      + sessions.put(sessionID, this);
      getLog().onEvent("Session " + this.sessionID + " schedule is " + sessionSchedule);
      if (!checkSessionTime())

      { getLog().onEvent("Session state is not current; resetting " + this.sessionID); reset(); }
      • sessions.put(sessionID, this);
        application.onCreate(sessionID);
        getLog().onEvent("Created session: " + sessionID);
        } catch (IOException e) { @@ -1692,4 +1692,4 @@ }

      -}
      \ No newline at end of file
      +}

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                admin Steve Bate
                Reporter:
                toli Toli Kuznets
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: