Skip to content

Commit b5197b8

Browse files
vpavicrwinch
authored andcommitted
Polish RedisIndexedSessionRepository
This commit addresses code warnings due to nullability of return values.
1 parent 2406ec8 commit b5197b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ public Map<String, RedisSession> findByIndexNameAndIndexValue(String indexName,
480480
}
481481
String principalKey = getPrincipalKey(indexValue);
482482
Set<Object> sessionIds = this.sessionRedisOperations.boundSetOps(principalKey).members();
483+
if (sessionIds == null) {
484+
return Collections.emptyMap();
485+
}
483486
Map<String, RedisSession> sessions = new HashMap<>(sessionIds.size());
484487
for (Object id : sessionIds) {
485488
RedisSession session = findById((String) id);
@@ -499,7 +502,7 @@ public Map<String, RedisSession> findByIndexNameAndIndexValue(String indexName,
499502
*/
500503
private RedisSession getSession(String id, boolean allowExpired) {
501504
Map<String, Object> entries = getSessionBoundHashOperations(id).entries();
502-
if (entries.isEmpty()) {
505+
if ((entries == null) || entries.isEmpty()) {
503506
return null;
504507
}
505508
MapSession loaded = new RedisSessionMapper(id).apply(entries);

0 commit comments

Comments
 (0)