Skip to content

Upgrade OkHttp from 4.12.0 to 5.4.0#2140

Draft
ramsessanchez wants to merge 1 commit into
mainfrom
upgrade-okhttp5
Draft

Upgrade OkHttp from 4.12.0 to 5.4.0#2140
ramsessanchez wants to merge 1 commit into
mainfrom
upgrade-okhttp5

Conversation

@ramsessanchez

Copy link
Copy Markdown
Contributor

Overview

Upgrades the OkHttp dependency from 4.12.0 to 5.4.0 for the components/http/okHttp module.

Changes

  • gradle/libs.versions.toml — bump okhttp to 5.4.0. The shared version.ref covers okhttp, logging-interceptor, and mockwebserver. The legacy com.squareup.okhttp3:mockwebserver artifact still ships in 5.x, so no package/artifact rename is needed.
  • RedirectHandler.javaokhttp3.internal.http.StatusLine no longer exposes HTTP_PERM_REDIRECT / HTTP_TEMP_REDIRECT in OkHttp 5. Replaced the removed internal imports with local 308 / 307 constants. This is the only production-source break.
  • OkHttpRequestAdapterTest.java — OkHttp 5 makes Response.Builder.body non-null, so .body(null) now throws NullPointerException. Removed those calls. Because a built success response now always carries a non-null (empty) body, the stream no-content test was split:
    • sendStreamReturnsNullOnNoContent — 204/304 still return null (via shouldReturnNull).
    • sendStreamReturnsEmptyStreamOnEmptyBody — 200-203 with an empty body yield a non-null empty stream, matching real OkHttp network behavior.

Notes

  • No production behavior change. The old null-body path was only reachable via synthetic mocks; real network responses always carry a non-null body. Production code is unchanged apart from the redirect constants.
  • okhttp3.* core packages are unchanged (no rename to an okhttp package).

Testing

  • ./gradlew :components:http:okHttp:test — 108 tests pass.
  • ./gradlew :components:bundle:test — pass (bundles okHttp).
  • The single unrelated failure in serialization:json (writesSampleObjectValueWithUntypedProperties) is pre-existing on main and independent of this change.

- Bump okhttp version in gradle/libs.versions.toml (covers okhttp,
  logging-interceptor and mockwebserver via the shared version ref).
- RedirectHandler: replace removed okhttp3.internal.http.StatusLine
  constants (HTTP_PERM_REDIRECT/HTTP_TEMP_REDIRECT) with local 308/307
  constants, as that internal class is no longer exposed in OkHttp 5.
- OkHttpRequestAdapterTest: OkHttp 5 Response.Builder.body is non-null,
  so drop .body(null) calls. Split the stream no-content test: 204/304
  still return null; 200-203 with an empty body now yield a non-null
  empty stream (matching real OkHttp behavior, production code unchanged).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 0b74528e-656e-4569-bb55-b833bbf51344
@ramsessanchez ramsessanchez requested a review from a team as a code owner July 14, 2026 23:33
@ramsessanchez ramsessanchez marked this pull request as draft July 14, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant