Upgrading com.squareup.okhttp3:mockwebserver 4 to 5
Breaking4.12.1 → 5.5.1Breaking17Security2Platform2New57Changed37Fixed71Other1
SecurityBlocks 8 compromised eMudhra intermediate certificates to protect JVMs and AOSP devices.Advisory ↗
BreakingUpgrade verdict
17 breaking changes and 2 platform requirement changes and 2 security fixes.
In plain terms
- 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.
Must act 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).
What you must change
Breaking17
Remove AddressPolicy, AsyncDns, and ConnectionListener from the public API.
AddressPolicyAsyncDnsConnectionListenerRename RecordedRequest.sequenceNumber to exchangeIndex and introduce connectionIndex on that type.
RecordedRequest.sequenceNumberexchangeIndexconnectionIndexRename RecordedRequest.path to RecordedRequest.target.
RecordedRequest.pathRecordedRequest.targetThe AndroidLogging class is no longer necessary.
AndroidLoggingLoggingEventListenerHttpLoggingInterceptorMove gzip from RequestBody to Request.Builder.
gzipRequestBodyRequest.BuilderContent-EncodingRecordedRequest.body is now nullable.
RecordedRequest.bodyRecordedRequest.chunkSizes is now nullable.
RecordedRequest.chunkSizesReplace SocketPolicy with a new type, SocketEffect.
SocketPolicySocketEffectReplace our parameters-based JUnit 5 extension with a new annotation, @StartStop.
@StartStopMockWebServerDon't automatically start MockWebServer after calls to accessors like port.
MockWebServerportIllegalStateExceptionDecompose the RecordedRequest.requestLine into three properties, method, target, and version.
RecordedRequest.requestLinemethodtargetversionChange RecordedRequest.body from a mutable Buffer to an immutable ByteString.
RecordedRequest.bodyBufferByteStringAdopt Okio's new Socket interface for MockResponse.socketHandler.
SocketMockResponse.socketHandlerMove coroutines extensions to okhttp3.coroutines.
okhttp3Tag unstable new APIs as @ExperimentalOkHttpApi.
@ExperimentalOkHttpApiUse kotlin.time.Duration in APIs like OkHttpClient.Builder.callTimeout().
kotlin.time.DurationOkHttpClient.Builder.callTimeout()DurationUnitReorder 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.sameSitePlatform2
ECH requires platform TLS stack support, which today is only Android 17 (API 37, released June 2026).
Drop support for Kotlin Multiplatform.
API changes
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