Open
Conversation
Test Results153 tests 153 ✅ 25s ⏱️ Results for commit 09a65d2. ♻️ This comment has been updated with latest results. |
3Juhwan
commented
Feb 17, 2026
Comment on lines
-30
to
-33
| sseEmitter.onTimeout(() -> { | ||
| emitters.remove(token); | ||
| log.debug("[SSE] 연결이 타임아웃으로 종료되었습니다. 현재 연결 수: {}", emitters.size()); | ||
| }); |
Member
Author
There was a problem hiding this comment.
아래 코드와 비교해보면 emitters.remove(token) -> emitters.remove(token, expectedEmitter) 로 변경했어요.
remove 에 key,value까지 정확히 맞는 경우에만 삭제합니다. 이로서 다음 케이스를 방지할 수 있는데요.
- T1: A 연결 등록 (token -> A)
- T2: 같은 token으로 B 재연결 (token -> B로 교체)
- T3: A의 timeout/completion 콜백이 지연 후 실행
- T4: 콜백이 무조건 remove(token)이면 현재 값(B)도 제거됨
- T5: 서버 입장에서는 최신 연결(B)이 사라져 전파 누락/연결수 오표시 가능
3Juhwan
commented
Feb 17, 2026
|
|
||
| if (previousEmitter != null) { | ||
| log.debug("[SSE] 기존 연결을 교체합니다. token: {}", token); | ||
| previousEmitter.completeWithError(new IllegalStateException("SSE emitter replaced by newer connection.")); |
Member
Author
There was a problem hiding this comment.
Suggested change
| previousEmitter.completeWithError(new IllegalStateException("SSE emitter replaced by newer connection.")); | |
| previousEmitter.complete(); | |
로 수정하는 게 낫겠군요~
- SSE 커넥션 재연결 시, 이전 emitter는 complete 처리
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경사항
ConcurrentMap<String, SseEmitter>로 변경하고, 실제 구현체로ConcurrentHashMap을 유지하여 동시성 의도와 구현을 일치시켰습니다.ConcurrentHashMap을 사용하는 이유getEmitters()/getUserTokens()가 스냅샷ArrayList복사본을 반환하는 이유removeIfSameEmitter(...))를 유지 및 연결하고,getEmitter()는Optional.ofNullable(emitters.get(token))형태로 단순화했습니다.TrackableSseEmitter를 활용한SseEmitterStorageTest를 추가하여 다음을 검증합니다.참고