Uh oh!
There was an error while loading. Please reload this page.
fix: 카카오/애플 외부 API 호출에 타임아웃 명시 - #243
Conversation
RestTemplate(카카오)과 OkHttpClient(애플, 기본 생성자)에 타임아웃이 없어서, 외부 서비스가 응답을 늦게 주면 그 요청을 처리하던 톰캣 스레드가 무제한 대기하게 되는 문제가 있었다. 스레드가 이런 식으로 계속 묶이면(누수) 카카오/애플 로그인과 무관한 다른 API 요청까지 스레드 풀 고갈로 영향을 받을 수 있다. - KakaoSignInService: RestTemplate에 SimpleClientHttpRequestFactory로 connect/read timeout 3초 설정 - AppleSignInService: JWKS 조회(RemoteJWKSet)에 DefaultResourceRetriever로 타임아웃 지정, 회원탈퇴 통보(OkHttpClient)에도 동일하게 적용 Google은 google-http-client 자체 기본 타임아웃(20초)이 이미 있어 이번 변경에서 제외.
📝 WalkthroughWalkthroughApple and Kakao authentication services now configure explicit HTTP timeouts for external API requests and Apple JWKS retrieval. ChangesAuthentication HTTP timeouts
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/org/runnect/server/auth/service/AppleSignInService.java`:
- Around line 56-59: Update the comment above CONNECT_TIMEOUT_MS and
READ_TIMEOUT_MS to accurately state that Nimbus JOSE + JWT 9.12 provides 500 ms
default connect and read timeouts; remove the claim that the default is
unlimited or that JWKS retrieval can wait indefinitely.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c56b4199-8aa7-4a4b-99e0-8bc6a147e16b
📒 Files selected for processing (2)
src/main/java/org/runnect/server/auth/service/AppleSignInService.javasrc/main/java/org/runnect/server/auth/service/KakaoSignInService.java
| // 애플 공개키(JWKS) 조회 및 회원탈퇴 통보에 타임아웃을 명시한다. 기본값(무제한 대기)이면 | ||
| // 애플 쪽이 응답을 늦게 줄 때 이 요청을 처리하던 톰캣 스레드가 계속 묶여있게 된다. | ||
| private static final int CONNECT_TIMEOUT_MS = 3000; | ||
| private static final int READ_TIMEOUT_MS = 3000; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bashset -euo pipefail
# Verify the default timeout behavior in the declared Nimbus JOSE + JWT version.
curl -fsSL \
https://repo1.maven.org/maven2/com/nimbusds/nimbus-jose-jwt/9.12/nimbus-jose-jwt-9.12-sources.jar \
-o /tmp/nimbus-jose-jwt-9.12-sources.jar
unzip -p /tmp/nimbus-jose-jwt-9.12-sources.jar \
com/nimbusds/jose/jwk/source/RemoteJWKSet.java |
rg -n -C 3 'DEFAULT_HTTP_(CONNECT|READ)_TIMEOUT|DefaultResourceRetriever'Repository: Runnect/Runnect-Spring-Boot-Server
Length of output: 2283
🏁 Script executed:
#!/bin/bashset -euo pipefail
printf'%s\n''--- dependency declarations ---'
rg -n -C 3 'nimbus-jose-jwt|okhttp' pom.xml build.gradle* gradle.properties 2>/dev/null ||trueprintf'%s\n''--- AppleSignInService.java relevant sections ---'
sed -n '1,180p' src/main/java/org/runnect/server/auth/service/AppleSignInService.javaRepository: Runnect/Runnect-Spring-Boot-Server
Length of output: 8025
Correct the JWKS timeout comment.
Nimbus JOSE + JWT 9.12 uses 500 ms connect and read timeouts by default. Remove the statement that JWKS retrieval can wait indefinitely.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/java/org/runnect/server/auth/service/AppleSignInService.java` around
lines 56 - 59, Update the comment above CONNECT_TIMEOUT_MS and READ_TIMEOUT_MS
to accurately state that Nimbus JOSE + JWT 9.12 provides 500 ms default connect
and read timeouts; remove the claim that the default is unlimited or that JWKS
retrieval can wait indefinitely.
로직이 수정/추가돼도 테스트가 안 따라오는 경우를 CI가 기계적으로 잡을 방법이 없었음(기존 CI는 기존 테스트 통과 여부만 확인). - JaCoco로 커버리지 리포트(xml) 생성 - diff-cover로 PR에서 실제로 바뀐 라인만 커버리지 검사(70% 미만 시 CI 실패) - 전체 커버리지 게이트가 아니라 diff 기준이라, 기존 미테스트 코드가 발목잡지 않으면서 "새로 바뀐 부분"만 강제함 로컬에서 기존 PR #243 diff로 실제 검증: KakaoSignInService(0%), AppleSignInService(16.7%) 등 테스트 없이 들어간 라인을 정확히 잡아냄. Co-authored-by: 나미 <dnska6657@gmail.com>
작업 배경
서킷 브레이커 도입을 검토하다가, 그보다 먼저 카카오/애플 로그인 호출에 타임아웃 자체가 없다는 걸 발견했다.
RestTemplate/OkHttpClient기본 생성자는 타임아웃이 없어서(무제한 대기), 카카오/애플이 응답을 늦게 주면 그 요청을 처리하던 톰캣 스레드가 계속 묶인다. 사용자가 재시도할수록 스레드가 하나씩 더 묶이고, 스레드 풀이 소진되면 로그인과 무관한 다른 API 요청까지 영향을 받는 구조였다(스레드 누수).변경 사항
KakaoSignInServiceRestTemplate에SimpleClientHttpRequestFactory로 connect/read timeout 3초 설정AppleSignInServiceRemoteJWKSet)에DefaultResourceRetriever로 타임아웃 지정, 회원탈퇴 통보(OkHttpClient)에도 동일 적용Google은
google-http-client자체 기본 타임아웃(20초)이 이미 있어 이번 변경에서 제외.영향 범위
UnauthorizedException계열)로 실패 처리됨 — 실패 자체는 동일하게 발생하던 상황(사용자는 결국 로그인 실패를 겪음)이고, 그 실패까지 걸리는 시간과 서버 스레드 점유 시간만 단축됨Test Plan
./gradlew test전체 254/254 통과AppleSignInServiceTest통과 확인 (Mock 기반이라 실제 타임아웃 동작은 검증 안 됨 — 실제 카카오/애플 서버 지연 상황 재현은 별도 필요)🤖 Generated with Claude Code
Summary by CodeRabbit