Skip to content

fix: 카카오/애플 외부 API 호출에 타임아웃 명시 - #243

Merged
unam98 merged 1 commit into
mainfrom
fix/external-api-call-timeouts
Aug 12, 2026
Merged

fix: 카카오/애플 외부 API 호출에 타임아웃 명시#243
unam98 merged 1 commit into
mainfrom
fix/external-api-call-timeouts

Conversation

@unam98

@unam98unam98 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

작업 배경

서킷 브레이커 도입을 검토하다가, 그보다 먼저 카카오/애플 로그인 호출에 타임아웃 자체가 없다는 걸 발견했다. RestTemplate/OkHttpClient 기본 생성자는 타임아웃이 없어서(무제한 대기), 카카오/애플이 응답을 늦게 주면 그 요청을 처리하던 톰캣 스레드가 계속 묶인다. 사용자가 재시도할수록 스레드가 하나씩 더 묶이고, 스레드 풀이 소진되면 로그인과 무관한 다른 API 요청까지 영향을 받는 구조였다(스레드 누수).

변경 사항

영역내용
KakaoSignInServiceRestTemplateSimpleClientHttpRequestFactory로 connect/read timeout 3초 설정
AppleSignInServiceJWKS 조회(RemoteJWKSet)에 DefaultResourceRetriever로 타임아웃 지정, 회원탈퇴 통보(OkHttpClient)에도 동일 적용

Google은 google-http-client 자체 기본 타임아웃(20초)이 이미 있어 이번 변경에서 제외.

영향 범위

  • 카카오/애플이 정상 응답하는 한 동작 변화 없음
  • 카카오/애플이 3초 넘게 응답 안 하면, 예전엔 무제한 대기하던 게 이제 3초 후 예외(UnauthorizedException 계열)로 실패 처리됨 — 실패 자체는 동일하게 발생하던 상황(사용자는 결국 로그인 실패를 겪음)이고, 그 실패까지 걸리는 시간과 서버 스레드 점유 시간만 단축됨

Test Plan

  • 로컬 postgres/redis 기동 후 ./gradlew test 전체 254/254 통과
  • 기존 AppleSignInServiceTest 통과 확인 (Mock 기반이라 실제 타임아웃 동작은 검증 안 됨 — 실제 카카오/애플 서버 지연 상황 재현은 별도 필요)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of Apple and Kakao sign-in requests by applying connection and response time limits.
    • Apple account withdrawal requests now consistently honor configured network timeouts.
    • Prevented authentication requests from hanging indefinitely when external services are slow or unavailable.

RestTemplate(카카오)과 OkHttpClient(애플, 기본 생성자)에 타임아웃이
없어서, 외부 서비스가 응답을 늦게 주면 그 요청을 처리하던 톰캣
스레드가 무제한 대기하게 되는 문제가 있었다. 스레드가 이런 식으로
계속 묶이면(누수) 카카오/애플 로그인과 무관한 다른 API 요청까지
스레드 풀 고갈로 영향을 받을 수 있다.
- KakaoSignInService: RestTemplate에 SimpleClientHttpRequestFactory로
connect/read timeout 3초 설정
- AppleSignInService: JWKS 조회(RemoteJWKSet)에 DefaultResourceRetriever로
타임아웃 지정, 회원탈퇴 통보(OkHttpClient)에도 동일하게 적용
Google은 google-http-client 자체 기본 타임아웃(20초)이 이미 있어
이번 변경에서 제외.
@coderabbitai

coderabbitaiBot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Apple and Kakao authentication services now configure explicit HTTP timeouts for external API requests and Apple JWKS retrieval.

Changes

Authentication HTTP timeouts

Layer / File(s)Summary
Apple network timeout configuration
src/main/java/org/runnect/server/auth/service/AppleSignInService.java
Apple JWKS retrieval uses explicit connection and read timeouts. Apple withdrawal requests use configured connection, read, and write timeouts.
Kakao API timeout configuration
src/main/java/org/runnect/server/auth/service/KakaoSignInService.java
The Kakao API RestTemplate uses a request factory with 3-second connection and read timeouts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers:funnysunny08, rinrinpark, yusuhwa-ve, alh0409

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly summarizes the main change: adding explicit timeouts to Kakao and Apple external API calls.
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/external-api-call-timeouts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unam98
unam98 merged commit b4c6ae3 into mainAug 12, 2026
2 checks passed
@unam98
unam98 deleted the fix/external-api-call-timeouts branch August 12, 2026 07:08

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d7e6d11 and ce5420c.

📒 Files selected for processing (2)
  • src/main/java/org/runnect/server/auth/service/AppleSignInService.java
  • src/main/java/org/runnect/server/auth/service/KakaoSignInService.java

Comment on lines +56 to +59
// 애플 공개키(JWKS) 조회 및 회원탈퇴 통보에 타임아웃을 명시한다. 기본값(무제한 대기)이면
// 애플 쪽이 응답을 늦게 줄 때 이 요청을 처리하던 톰캣 스레드가 계속 묶여있게 된다.
private static final int CONNECT_TIMEOUT_MS = 3000;
private static final int READ_TIMEOUT_MS = 3000;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.java

Repository: 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.

unam98 added a commit that referenced this pull request Aug 12, 2026
로직이 수정/추가돼도 테스트가 안 따라오는 경우를 CI가 기계적으로
잡을 방법이 없었음(기존 CI는 기존 테스트 통과 여부만 확인).
- JaCoco로 커버리지 리포트(xml) 생성
- diff-cover로 PR에서 실제로 바뀐 라인만 커버리지 검사(70% 미만 시 CI 실패)
- 전체 커버리지 게이트가 아니라 diff 기준이라, 기존 미테스트 코드가
발목잡지 않으면서 "새로 바뀐 부분"만 강제함
로컬에서 기존 PR #243 diff로 실제 검증: KakaoSignInService(0%),
AppleSignInService(16.7%) 등 테스트 없이 들어간 라인을 정확히 잡아냄.
Co-authored-by: 나미 <dnska6657@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@unam98@alh0409