1
0
mirror of synced 2026-08-03 08:51:58 +00:00

SEC-1372: Return an empty list rather than null from SessionRegistryImpl.getAllSessions()

If the principal has no sessions, null is returned which contradicts the interface contract. In practice it didn't matter as the null was checked for, but it is cleaner to disallow a null value.
This commit is contained in:
Luke Taylor
2010-01-19 01:07:33 +00:00
parent 8137a8bcd0
commit 1a7f71fc0f
3 changed files with 4 additions and 4 deletions
@@ -62,7 +62,7 @@ public class SessionRegistryImpl implements SessionRegistry, ApplicationListener
final Set<String> sessionsUsedByPrincipal = principals.get(principal);
if (sessionsUsedByPrincipal == null) {
return null;
return Collections.emptyList();
}
List<SessionInformation> list = new ArrayList<SessionInformation>(sessionsUsedByPrincipal.size());
@@ -117,7 +117,7 @@ public class SessionRegistryImplTests {
// Check attempts to retrieve cleared session return null
assertNull(sessionRegistry.getSessionInformation(sessionId));
assertNull(sessionRegistry.getAllSessions(principal, false));
assertEquals(0, sessionRegistry.getAllSessions(principal, false).size());
}
@Test
@@ -168,7 +168,7 @@ public class SessionRegistryImplTests {
sessionRegistry.removeSessionInformation(sessionId2);
assertNull(sessionRegistry.getSessionInformation(sessionId2));
assertNull(sessionRegistry.getAllSessions(principal, false));
assertEquals(0, sessionRegistry.getAllSessions(principal, false).size());
}
private boolean contains(String sessionId, Object principal) {