Skip to content

Commit d02d25c

Browse files
Update InMemorySessionService.java
1 parent 05c7b7f commit d02d25c

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

core/src/main/java/com/google/adk/sessions/InMemorySessionService.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,21 @@ public Completable deleteSession(String appName, String userId, String sessionId
186186
Objects.requireNonNull(userId, "userId cannot be null");
187187
Objects.requireNonNull(sessionId, "sessionId cannot be null");
188188

189-
sessions.computeIfPresent(appName, (app, appSessionsMap) -> {
190-
appSessionsMap.computeIfPresent(userId, (user, userSessionsMap) -> {
191-
userSessionsMap.remove(sessionId);
192-
// If userSessionsMap is now empty, return null to automatically remove the userId key
193-
return userSessionsMap.isEmpty() ? null : userSessionsMap;
189+
sessions.computeIfPresent(
190+
appName,
191+
(app, appSessionsMap) -> {
192+
appSessionsMap.computeIfPresent(
193+
userId,
194+
(user, userSessionsMap) -> {
195+
userSessionsMap.remove(sessionId);
196+
// If userSessionsMap is now empty, return null to automatically remove the userId
197+
// key
198+
return userSessionsMap.isEmpty() ? null : userSessionsMap;
199+
});
200+
// If appSessionsMap is now empty, return null to automatically remove the appName key
201+
return appSessionsMap.isEmpty() ? null : appSessionsMap;
194202
});
195-
// If appSessionsMap is now empty, return null to automatically remove the appName key
196-
return appSessionsMap.isEmpty() ? null : appSessionsMap;
197-
});
198-
203+
199204
return Completable.complete();
200205
}
201206

0 commit comments

Comments
 (0)