Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion quickfixj-core/src/main/java/quickfix/mina/SessionConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ public boolean isLoggedOn() {
return true;
}

/**
* Check if we have at least one session and that at least one session is logged on.
*
* @return false if no sessions exist or all sessions are logged off, true otherwise
*/
//visible for testing only
boolean anyLoggedOn() {
// if no session, not logged on
if (sessions.isEmpty())
return false;
for (Session session : sessions.values()) {
// at least one session logged on
if (session.isLoggedOn())
return true;
}
// no sessions are logged on
return false;
}

private Set<quickfix.Session> getLoggedOnSessions() {
Set<quickfix.Session> loggedOnSessions = new HashSet<>(sessions.size());
for (Session session : sessions.values()) {
Expand All @@ -219,7 +238,7 @@ protected void logoutAllSessions(boolean forceDisconnect) {
}
}

if (isLoggedOn()) {
if (anyLoggedOn()) {
if (forceDisconnect) {
for (Session session : sessions.values()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void testOneSessionLoggedOnOneSessionNotLoggedOne() throws Exception {
assertNotNull(session2);
sessions.put(session2.getSessionID(), session2);
assertFalse(connector.isLoggedOn());
assertTrue(connector.anyLoggedOn());
}

/**
Expand Down