Skip to content

reset disabled session per SessionSchedule to avoid message loss#1181

Open
Ra9huvansh wants to merge 1 commit intoquickfix-j:masterfrom
Ra9huvansh:fix-965-disabled-session-reset
Open

reset disabled session per SessionSchedule to avoid message loss#1181
Ra9huvansh wants to merge 1 commit intoquickfix-j:masterfrom
Ra9huvansh:fix-965-disabled-session-reset

Conversation

@Ra9huvansh
Copy link
Copy Markdown

Fixes #965

When a session is disabled (e.g. after calling logout()) and has no active connection, Session.next() was returning early before it could reach the SessionSchedule check. This meant that even if the session schedule said it was time to reset, the reset never happened.

The problem shows up when messages are sent via sendToTarget() to a disabled session. They get queued in the message store and advance the sequence numbers. When next() is called by the internal timer, it hits the early return and exits without resetting, so those queued messages are never cleared. The next time the session connects, the sequence numbers are wrong and messages are effectively lost.

The fix is straightforward. Instead of returning immediately when the session is disabled and not logged on, we now let execution fall through to the session schedule block first, and return after it. The existing state.isResetNeeded() check already handles @philipwhiuk's suggestion of only resetting when sequence numbers have actually advanced beyond 1, so no extra logic was needed there.

Changes:

  • Session.java: removed the early return for the disabled+not-logged-on case in next(), added the guard after the schedule block instead
  • SessionTest.java: added testDisabledSessionIsResetBySchedule which reproduces the exact scenario from the bug report

Tests run:

  • SessionTest — 72/72 passing (includes the new test)
  • Full quickfixj-core test suite — 0 failures, 0 errors

@chrjohn chrjohn changed the title Fix QFJ-965: reset disabled session per SessionSchedule to avoid message loss reset disabled session per SessionSchedule to avoid message loss Apr 8, 2026
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

Successfully merging this pull request may close these issues.

Enabling a previously disabled session might lead to message loss

1 participant