Skip to content

Commit 3868404

Browse files
upchuckchrjohn
authored andcommitted
Re-enabled acceptor sessions in finally block (#126)
* Re-enabled acceptor sessions in finally block The Acceptor sessions should get re-enabled if socket was disconnected during logout. When the following disconnect code runs it skips re-enable the acceptor session. if (!hasResponder()) { if (!ENCOUNTERED_END_OF_STREAM.equals(reason)) { getLog().onEvent("Already disconnected: " + reason); } return; } * Re-enabled acceptor sessions in finally block - corrected unit test
1 parent f4d9d60 commit 3868404

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

quickfixj-core/src/main/java/quickfix/Session.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,11 +2032,12 @@ public void disconnect(String reason, boolean logError) throws IOException {
20322032

20332033
stateListener.onLogout();
20342034
}
2035+
} finally {
20352036
// QFJ-457 now enabled again if acceptor
20362037
if (!state.isInitiator()) {
20372038
setEnabled(true);
20382039
}
2039-
} finally {
2040+
20402041
state.setLogonReceived(false);
20412042
state.setLogonSent(false);
20422043
state.setLogoutSent(false);

quickfixj-core/src/test/java/quickfix/mina/SessionConnectorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public void testConnector() throws Exception {
7979

8080
assertTrue(session.isEnabled());
8181
connector.logoutAllSessions(true);
82-
assertFalse(session.isEnabled());
82+
// Acceptors should get re-enabled after Logout
83+
assertTrue(session.isEnabled());
8384

8485
assertEquals(9999, connector.getIntSetting(Acceptor.SETTING_SOCKET_ACCEPT_PORT));
8586

0 commit comments

Comments
 (0)