Skip to content

Upgrading com.squareup.okhttp3:mockwebserver 4 to 5

Breaking4.12.1 → 5.5.1Breaking17Security2Platform2New57Changed37Fixed71Other1

BreakingUpgrade verdict

17 breaking changes and 2 platform requirement changes and 2 security fixes.

  • Remove AddressPolicy, AsyncDns, and ConnectionListener from the public API.
  • Rename RecordedRequest.sequenceNumber to exchangeIndex and introduce connectionIndex on that type.
  • Rename RecordedRequest.path to RecordedRequest.target.
  • The AndroidLogging class is no longer necessary.
Top 5 of 21 that need code or config changes

Adds com.squareup.okhttp3:mockwebserver3 5.5.1, com.squareup.okhttp3:okhttp-jvm 5.5.1, com.squareup.okio:okio-jvm 3.18.1, org.jetbrains.kotlin:kotlin-stdlib 2.1.21.

Drops com.squareup.okhttp3:okhttp, org.jetbrains.kotlin:kotlin-stdlib-jdk8.

Installs 7 packages in all (was 10).

Breaking17
Remove AddressPolicy, AsyncDns, and ConnectionListener from the public API.
AddressPolicyAsyncDnsConnectionListener
Rename RecordedRequest.sequenceNumber to exchangeIndex and introduce connectionIndex on that type.
RecordedRequest.sequenceNumberexchangeIndexconnectionIndex
Rename RecordedRequest.path to RecordedRequest.target.
RecordedRequest.pathRecordedRequest.target
The AndroidLogging class is no longer necessary.
AndroidLoggingLoggingEventListenerHttpLoggingInterceptor
Move gzip from RequestBody to Request.Builder.
gzipRequestBodyRequest.BuilderContent-Encoding
RecordedRequest.body is now nullable.
RecordedRequest.body
RecordedRequest.chunkSizes is now nullable.
RecordedRequest.chunkSizes
Replace SocketPolicy with a new type, SocketEffect.
SocketPolicySocketEffect
Replace our parameters-based JUnit 5 extension with a new annotation, @StartStop.
@StartStopMockWebServer
Don't automatically start MockWebServer after calls to accessors like port.
MockWebServerportIllegalStateException
Decompose the RecordedRequest.requestLine into three properties, method, target, and version.
RecordedRequest.requestLinemethodtargetversion
Change RecordedRequest.body from a mutable Buffer to an immutable ByteString.
RecordedRequest.bodyBufferByteString
Adopt Okio's new Socket interface for MockResponse.socketHandler.
SocketMockResponse.socketHandler
Move coroutines extensions to okhttp3.coroutines.
okhttp3
Tag unstable new APIs as @ExperimentalOkHttpApi.
@ExperimentalOkHttpApi
Use kotlin.time.Duration in APIs like OkHttpClient.Builder.callTimeout().
kotlin.time.DurationOkHttpClient.Builder.callTimeout()DurationUnit
Reorder the parameters in the Cache constructor that was introduced in 5.0.0-alpha.3.
Security2
Blocks 8 compromised eMudhra intermediate certificates to protect JVMs and AOSP devices.
Cookie.sameSite determines whether cookies should be sent on cross-site requests.
Cookie.sameSite
Platform2
ECH requires platform TLS stack support, which today is only Android 17 (API 37, released June 2026).
Drop support for Kotlin Multiplatform.

Generated by DepDelta from published JVM bytecode. Not mixed with prose notes.

  • removed: abstract class MwsDuplexAccess
  • removed: ctor MwsDuplexAccess()
  • removed: method MwsDuplexAccess.setBody(MockResponse, DuplexResponseBody): void
  • removed: static field MwsDuplexAccess.Companion: MwsDuplexAccess.Companion
  • removed: static field MwsDuplexAccess.instance: MwsDuplexAccess
  • removed: static final class MwsDuplexAccess.Companion
  • removed: ctor MockWebServer.SocketHandler(MockWebServer, Socket)
  • removed: final class MockWebServer.SocketHandler
  • removed: method MockResponse.addInformationalResponse(MockResponse): MockResponse
  • removed: method MockResponse.getDuplexResponseBody(): DuplexResponseBody
  • removed: method MockResponse.getInformationalResponses$mockwebserver(): List
  • removed: method MockResponse.isDuplex(): boolean
  • removed: method MockResponse.setBody(DuplexResponseBody): MockResponse
  • removed: method MockResponse.setInformationalResponses$mockwebserver(List): void
  • removed: method MockWebServer.SocketHandler.handle(): void
  • removed: method QueueDispatcher.getResponseQueue(): BlockingQueue
  • removed: static field QueueDispatcher.Companion: QueueDispatcher.Companion
  • removed: static final class QueueDispatcher.Companion
  • changed: class QueueDispatcher extends Dispatcher → final class QueueDispatcher extends Dispatcher
  • added: ctor RecordedRequest(String, Headers, List, long, Buffer, int, IOException, String, String, Handshake, HttpUrl)
  • added: final class DeprecationBridgeKt
  • added: method MockWebServer.getDelegate(): MockWebServer
  • added: method QueueDispatcher.getDelegate$mockwebserver(): QueueDispatcher
  • added: static method DeprecationBridgeKt.unwrap(RecordedRequest): RecordedRequest
  • added: static method DeprecationBridgeKt.wrap(Dispatcher): Dispatcher
  • added: static method DeprecationBridgeKt.wrap(MockResponse): MockResponse
  • added: static method SocketPolicy.getEntries(): EnumEntries
  • removed: ctor MockDuplexResponseBody()
  • removed: final class MockDuplexResponseBody implements DuplexResponseBody
  • removed: final class MockDuplexResponseBodyKt
  • removed: interface DuplexResponseBody
  • removed: method DuplexResponseBody.onRequest(RecordedRequest, Http2Stream): void
  • removed: method MockDuplexResponseBody.awaitSuccess(): void
  • removed: method MockDuplexResponseBody.cancelStream(ErrorCode): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.exhaustRequest(): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.exhaustResponse(): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.onRequest(RecordedRequest, Http2Stream): void
  • removed: method MockDuplexResponseBody.receiveRequest(String): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.requestIOException(): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.sendResponse(String): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.sendResponse(String, CountDownLatch): MockDuplexResponseBody
  • removed: method MockDuplexResponseBody.sleep(long, TimeUnit): MockDuplexResponseBody