Skip to content

[Refactor/#196] 네트워크 모듈 리팩토링 및 라이브러리 업데이트#197

Open
wjdrjs00 wants to merge 5 commits intodevelopfrom
refactor/#196-network-layer-improvement
Open

[Refactor/#196] 네트워크 모듈 리팩토링 및 라이브러리 업데이트#197
wjdrjs00 wants to merge 5 commits intodevelopfrom
refactor/#196-network-layer-improvement

Conversation

@wjdrjs00
Copy link
Member

@wjdrjs00 wjdrjs00 commented Mar 17, 2026

[ PR Content ]

Related issue

Work Description

  • NetworkModule & ServiceModule 리팩토링:
    • NetworkModule.kt: 중복되던 OkHttpClient 설정 로직을 BaseOkHttpClient로 추출
  • 인증 로직 고도화:
    • AuthInterceptor.kt 및 TokenAuthenticator.kt에서 더 이상 사용하지 않는 Auto-Login 관련 헤더 로직을 제거하였습니다.
    • 인증이 필요 없는 로그인 관련 API를 별도의 LoginService로 분리하여 계층 구조를 명확히 하였습니다.
  • 라이브러리 버전 업데이트:
    • libs.versions.toml: OkHttp를 4.11.0에서 5.3.2로, Retrofit을 2.11.0에서 3.0.0으로 업데이트

To Reviewers 📢

  • 기존 방식은 @Auth, @NoneAuth, @Kakao 등 각각의 목적에 맞는 클라이언트를 생성할 때 매번 OkHttpClient.Builder().build()를 독립적으로 호출합니다. 이 경우 클라이언트가 생성될 때마다 내부적으로 별도의 커넥션 풀과 스레드 풀이 각각 새로 만들어지는 문제가 있습니다. 이를 baseClient.newBuilder()를 활용해 단일 Base 클라이언트를 하나만 생성하고 이를 기반으로 생성되도록 수정했습니다.
    개선 효과: 앱 전체의 네트워크 요청이 단 1개의 스레드풀과 커넥션풀을 공유하게 됩니다!

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 로그인 및 토큰 재발급 기능을 위한 통합 서비스 추가
  • 개선사항

    • 네트워크 인증 처리 로직 간소화
    • OkHttp 5.3.2, Retrofit 3.0.0으로 업데이트하여 네트워크 성능 및 안정성 향상
  • 리팩토링

    • 의존성 주입 구조 최적화로 서비스 모듈 재구성

@wjdrjs00 wjdrjs00 requested a review from l5x5l March 17, 2026 12:57
@wjdrjs00 wjdrjs00 self-assigned this Mar 17, 2026
@wjdrjs00 wjdrjs00 added 🔨 Refactor 기존 기능 개선 🧤 대현 labels Mar 17, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Walkthrough

이 PR은 네트워크 모듈의 구조를 개선하는 대규모 리팩토링입니다. OkHttpClient 구성을 기본 클라이언트에서 특화된 클라이언트로 분리하고, 로그인 기능을 AuthService에서 새로운 LoginService로 분리했습니다. 또한 불필요한 헤더 처리 로직을 제거하고 OkHttp와 Retrofit을 최신 버전으로 업데이트했습니다.

Changes

Cohort / File(s) Summary
네트워크 모듈 기본 구조
app/src/main/java/com/threegap/bitnagil/di/core/NetworkModule.kt, app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt
OkHttpClient를 기본 클라이언트와 특화된 클라이언트(NoneAuth, Auth, Kakao)로 분리. Retrofit 서비스 생성 로직을 단순화하고 타입 추론 사용. 여러 서비스 제공자의 한정자(qualifier) 재배치.
인증 로직 정리
core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt, core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt
No-Service-Token 및 Auto-Login 헤더 처리 로직 제거. 토큰이 유효한 경우에만 Authorization 헤더 추가.
서비스 재구성
data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt, data/src/main/java/com/threegap/bitnagil/data/auth/service/LoginService.kt, data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt
로그인 기능(postLogin, postReissueToken)을 AuthService에서 새로운 LoginService로 이전. AuthRemoteDataSourceImpl에 LoginService 의존성 추가.
의존성 업데이트
gradle/libs.versions.toml
OkHttp를 4.11.0에서 5.3.2로, Retrofit을 2.11.0에서 3.0.0으로 업데이트.
빌드 설정
build-logic/convention/src/main/java/com/threegap/bitnagil/convention/extension/KotlinAndroid.kt
패키징 리소스 제외 목록에 "META-INF/versions/9/OSGI-INF/MANIFEST.MF" 추가.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 네트워크 길을 정리하는 토끼,
기본에서 특화로, 깔끔한 흐름,
로그인 서비스 분리하고,
불필요한 헤더는 모두 제거,
더 신선한 라이브러리로 뛰어올라! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 주요 변경사항인 네트워크 모듈 리팩토링과 라이브러리 업데이트를 명확하게 요약합니다.
Linked Issues check ✅ Passed 모든 코드 변경사항이 이슈 #196의 목표인 NetworkModule 리팩토링, 인증 로직 간소화, 라이브러리 업데이트를 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #196의 요구사항 범위 내에 있으며 범위를 벗어난 변경은 없습니다.
Description check ✅ Passed PR 설명은 템플릿의 필수 섹션(Related issue, Work Description, To Reviewers)을 모두 포함하며, 변경사항을 명확하게 설명하고 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#196-network-layer-improvement
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Tip

You can disable poems in the walkthrough.

Disable the reviews.poem setting to disable the poems in the walkthrough.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/main/java/com/threegap/bitnagil/di/core/NetworkModule.kt`:
- Around line 104-120: The None-auth and Auth OkHttp clients created by
provideNoneAuthOkHttpClient and provideAuthOkHttpClient currently share the
baseClient Dispatcher via OkHttpClient.newBuilder(), which can cause
deadlock/starvation when TokenAuthenticator does runBlocking reissue calls; fix
by creating a dedicated Dispatcher for the auth/reissue path and assign it to
the auth client builder (use a new Dispatcher with its own executor or thread
pool) so the client used by TokenAuthenticator/ReissueService does not share the
baseClient dispatcher; update provideAuthOkHttpClient to set that Dispatcher on
the newBuilder() before build().

In
`@core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt`:
- Line 15: AuthInterceptor currently does a pass-through when
token.isNullOrBlank() which causes TokenAuthenticator.authenticate() to treat
the 401 as unauthenticated and attempt unnecessary refreshes; update
AuthInterceptor.intercept to either fail-fast for auth-only clients (e.g., throw
an IOException or return an immediate 401-like failure) when token is absent, or
annotate the outgoing request with a skip-refresh marker header (e.g.,
"X-Skip-Refresh": "1") so TokenAuthenticator.authenticate() can check that
header and avoid refresh logic; modify TokenAuthenticator.authenticate()
accordingly to short-circuit refresh when that header is present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6248c669-7484-49b5-a137-7ae4a0bbb2ca

📥 Commits

Reviewing files that changed from the base of the PR and between d289f4a and 91a9870.

📒 Files selected for processing (9)
  • app/src/main/java/com/threegap/bitnagil/di/core/NetworkModule.kt
  • app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt
  • build-logic/convention/src/main/java/com/threegap/bitnagil/convention/extension/KotlinAndroid.kt
  • core/network/src/main/java/com/threegap/bitnagil/network/auth/AuthInterceptor.kt
  • core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt
  • data/src/main/java/com/threegap/bitnagil/data/auth/datasourceimpl/AuthRemoteDataSourceImpl.kt
  • data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt
  • data/src/main/java/com/threegap/bitnagil/data/auth/service/LoginService.kt
  • gradle/libs.versions.toml
💤 Files with no reviewable changes (2)
  • data/src/main/java/com/threegap/bitnagil/data/auth/service/AuthService.kt
  • core/network/src/main/java/com/threegap/bitnagil/network/auth/TokenAuthenticator.kt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 기존 기능 개선 🧤 대현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 네트워크 모듈 구조 개선 및 라이브러리 버전 업데이트

1 participant