1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-07 12:42:57 +03:00

Temporarily remove ConnectionListener from the public API (#8831)

I'd like to update the API to improve observability into things
like ConnecitonPool, RoutePlanner, ConnectPlan, and ReusePlan.
And also into HTTP/2 internals like flow-control.

As-is this is more coupled to Call lifecycles and is somewhat
duplicative with ConnectionPool.

We'll do that work and make it a new public API, but we won't
have it in the public API at all for the 5.0 release.

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
This commit is contained in:
Jesse Wilson
2025-05-30 17:28:20 -04:00
committed by GitHub
parent f141d4df96
commit 80c71d2129
15 changed files with 32 additions and 92 deletions

View File

@@ -13,6 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress(
"CANNOT_OVERRIDE_INVISIBLE_MEMBER",
"INVISIBLE_MEMBER",
"INVISIBLE_REFERENCE",
)
package okhttp3

View File

@@ -60,7 +60,7 @@ class OkHttpClientTestRule :
private lateinit var testName: String
private var defaultUncaughtExceptionHandler: Thread.UncaughtExceptionHandler? = null
private var taskQueuesWereIdle: Boolean = false
val connectionListener = RecordingConnectionListener()
private val connectionListener = RecordingConnectionListener()
var logger: Logger? = null

View File

@@ -13,6 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress(
"CANNOT_OVERRIDE_INVISIBLE_MEMBER",
"INVISIBLE_MEMBER",
"INVISIBLE_REFERENCE",
)
package okhttp3
import assertk.assertThat
@@ -24,11 +30,12 @@ import java.util.Deque
import java.util.concurrent.ConcurrentLinkedDeque
import java.util.concurrent.TimeUnit
import okhttp3.ConnectionEvent.NoNewExchanges
import okhttp3.internal.connection.ConnectionListener
import okhttp3.internal.connection.RealConnection
import okio.IOException
import org.junit.jupiter.api.Assertions
open class RecordingConnectionListener(
internal open class RecordingConnectionListener(
/**
* An override to ignore the normal order that is enforced.
* EventListeners added by Interceptors will not see all events.

View File

@@ -36,6 +36,7 @@ import okhttp3.internal.concurrent.TaskFaker
import okhttp3.internal.concurrent.TaskRunner
import okhttp3.internal.concurrent.withLock
import okhttp3.internal.connection.CallConnectionUser
import okhttp3.internal.connection.ConnectionListener
import okhttp3.internal.connection.FastFallbackExchangeFinder
import okhttp3.internal.connection.RealCall
import okhttp3.internal.connection.RealConnection

View File

@@ -1,40 +0,0 @@
/*
* Copyright (C) 2023 Block, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.internal.http2
import okhttp3.ConnectionListener
import okhttp3.internal.http2.flowcontrol.WindowCounter
/**
* ConnectionListener that outputs CSV for flow control of client receiving streams.
*/
class Http2FlowControlConnectionListener :
ConnectionListener(),
FlowControlListener {
val start = System.currentTimeMillis()
override fun receivingStreamWindowChanged(
streamId: Int,
windowCounter: WindowCounter,
bufferSize: Long,
) {
println("${System.currentTimeMillis() - start},$streamId,${windowCounter.unacknowledged},$bufferSize")
}
override fun receivingConnectionWindowChanged(windowCounter: WindowCounter) {
println("${System.currentTimeMillis() - start},0,${windowCounter.unacknowledged},")
}
}