Skip to content

Commit ce7eb0c

Browse files
committed
refector: SSE 유저 상태 완전 제거 로직 추가
1 parent 3df7a32 commit ce7eb0c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/store/lastdance/service/notification/SSENotificationV2ServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,12 @@ private void cleanupConnection(UUID userId, String connectionId, SseEmitter emit
146146
}
147147

148148
private void cleanupSingleConnection(UUID userId, String connectionId) {
149-
// heartbeat 취소
150149
ConcurrentHashMap<String, ScheduledFuture<?>> userTasks = heartbeatTasks.get(userId);
151150
if (userTasks != null) {
152151
ScheduledFuture<?> task = userTasks.remove(connectionId);
153152
if (task != null) task.cancel(true);
154153
}
155154

156-
// emitter 종료
157155
ConcurrentHashMap<String, SseEmitter> userConnections = connections.get(userId);
158156
if (userConnections != null) {
159157
SseEmitter emitter = userConnections.remove(connectionId);
@@ -166,6 +164,13 @@ private void cleanupSingleConnection(UUID userId, String connectionId) {
166164
}
167165
}
168166

167+
if (userConnections != null && userConnections.isEmpty()) {
168+
connections.remove(userId);
169+
heartbeatTasks.remove(userId);
170+
userLocks.remove(userId);
171+
log.debug("SSE 유저 상태 완전 제거 (마지막 연결 정리): userId={}", userId);
172+
}
173+
169174
log.debug("SSE 단일 연결 정리: userId={}, connectionId={}", userId, connectionId);
170175
}
171176

0 commit comments

Comments
 (0)