File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,25 @@ public boolean isLoggedOn() {
195
195
return true ;
196
196
}
197
197
198
+ /**
199
+ * Check if we have at least one session and that at least one session is logged on.
200
+ *
201
+ * @return false if no sessions exist or all sessions are logged off, true otherwise
202
+ */
203
+ //visible for testing only
204
+ boolean anyLoggedOn () {
205
+ // if no session, not logged on
206
+ if (sessions .isEmpty ())
207
+ return false ;
208
+ for (Session session : sessions .values ()) {
209
+ // at least one session logged on
210
+ if (session .isLoggedOn ())
211
+ return true ;
212
+ }
213
+ // no sessions are logged on
214
+ return false ;
215
+ }
216
+
198
217
private Set <quickfix .Session > getLoggedOnSessions () {
199
218
Set <quickfix .Session > loggedOnSessions = new HashSet <>(sessions .size ());
200
219
for (Session session : sessions .values ()) {
@@ -219,7 +238,7 @@ protected void logoutAllSessions(boolean forceDisconnect) {
219
238
}
220
239
}
221
240
222
- if (isLoggedOn ()) {
241
+ if (anyLoggedOn ()) {
223
242
if (forceDisconnect ) {
224
243
for (Session session : sessions .values ()) {
225
244
try {
Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ public void testOneSessionLoggedOnOneSessionNotLoggedOne() throws Exception {
129
129
assertNotNull (session2 );
130
130
sessions .put (session2 .getSessionID (), session2 );
131
131
assertFalse (connector .isLoggedOn ());
132
+ assertTrue (connector .anyLoggedOn ());
132
133
}
133
134
134
135
/**
You can’t perform that action at this time.
0 commit comments