Skip to content

Commit 96345cf

Browse files
committed
Swap order of new member in AddressPolicy
1 parent a4befc3 commit 96345cf

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

‎okhttp/api/okhttp.api‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ public final class okhttp3/ConnectionPool$AddressPolicy {
393393
public final field maximumConcurrentCallsPerConnection I
394394
public final field minimumConcurrentCalls I
395395
public fun <init> ()V
396-
public fun <init> (IIJI)V
397-
public synthetic fun <init> (IIJIILkotlin/jvm/internal/DefaultConstructorMarker;)V
396+
public fun <init> (IJII)V
397+
public synthetic fun <init> (IJIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
398398
}
399399

400400
public final class okhttp3/ConnectionSpec {

‎okhttp/src/main/kotlin/okhttp3/ConnectionPool.kt‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,14 @@ class ConnectionPool internal constructor(
148148
* Connections will still be closed if they idle beyond the keep-alive but will be replaced.
149149
*/
150150
@JvmField val minimumConcurrentCalls: Int = 0,
151+
/** How long to wait to retry pre-emptive connection attempts that fail. */
152+
@JvmField val backoffDelayMillis: Long = 60 * 1000,
153+
/** How much jitter to introduce in connection retry backoff delays */
154+
@JvmField val backoffJitterMillis: Int = 100,
151155
/**
152156
* The maximum number of concurrent calls per connection.
153-
*
154157
* Set this value to 1 to disable HTTP/2 connection coalescing
155158
*/
156159
@JvmField val maximumConcurrentCallsPerConnection: Int = Int.MAX_VALUE,
157-
/** How long to wait to retry pre-emptive connection attempts that fail. */
158-
@JvmField val backoffDelayMillis: Long = 60 * 1000,
159-
/** How much jitter to introduce in connection retry backoff delays */
160-
@JvmField val backoffJitterMillis: Int = 100,
161160
)
162161
}

‎okhttp/src/main/kotlin/okhttp3/internal/connection/RealConnection.kt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class RealConnection(
357357
connection: Http2Connection,
358358
settings: Settings,
359359
) {
360-
this.withLock {
360+
this.withLock {
361361
this.lastMaxConcurrentStreamsFromSettings = settings.getMaxConcurrentStreams()
362362
recalculateAllocationLimit()
363363
}
@@ -369,7 +369,7 @@ class RealConnection(
369369
* made during settings changes
370370
*/
371371
internal fun recalculateAllocationLimit() {
372-
this.withLock {
372+
this.withLock {
373373
val oldLimit = allocationLimit
374374
allocationLimit = getMaximumAllocationLimit()
375375

@@ -425,7 +425,7 @@ class RealConnection(
425425
e: IOException?,
426426
) {
427427
var noNewExchangesEvent = false
428-
this.withLock {
428+
this.withLock {
429429
if (e is StreamResetException) {
430430
when {
431431
e.errorCode == ErrorCode.REFUSED_STREAM -> {

‎okhttp/src/test/java/okhttp3/internal/connection/ConnectionPoolTest.kt‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class ConnectionPoolTest {
277277

278278
// Add a connection to the pool that won't expire for a while
279279
routePlanner.defaultConnectionIdleAtNanos = expireLater
280-
setPolicy(pool, address, ConnectionPool.AddressPolicy(1))
280+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 1))
281281
assertThat(pool.connectionCount()).isEqualTo(1)
282282

283283
// All other connections created will expire sooner
@@ -287,31 +287,31 @@ class ConnectionPoolTest {
287287
// which can satisfy a larger policy
288288
val connection = routePlanner.plans.first().connection
289289
val http2Connection = connectHttp2(peer, connection, 5)
290-
setPolicy(pool, address, ConnectionPool.AddressPolicy(5))
290+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 5))
291291
assertThat(pool.connectionCount()).isEqualTo(1)
292292

293293
// Decrease the policy max connections, and check that new connections are created
294-
setPolicy(pool, address, ConnectionPool.AddressPolicy(5, 1))
294+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 5, maximumConcurrentCallsPerConnection = 1))
295295
// fills up the first connect and then adds single connections
296296
// 5 = 1 + 1 + 1 + 1 + 1 (five unique connections)
297297
assertThat(pool.connectionCount()).isEqualTo(5)
298298

299299
// increase the policy max connections, and check that new connections are created
300-
setPolicy(pool, address, ConnectionPool.AddressPolicy(5, 2))
300+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 5, maximumConcurrentCallsPerConnection = 2))
301301
forceConnectionsToExpire(pool, expireSooner)
302302
// fills up the first connect and then adds single connections
303303
// 5 = 2 + 1 + 1 + 1 (four unique connections)
304304
assertThat(pool.connectionCount()).isEqualTo(4)
305305

306306
// increase the policy max connections, and check that new connections are created
307-
setPolicy(pool, address, ConnectionPool.AddressPolicy(5, 4))
307+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 5, maximumConcurrentCallsPerConnection = 4))
308308
forceConnectionsToExpire(pool, expireSooner)
309309
// fills up the first connect and then adds single connections
310310
// 5 = 4 + 1 (two unique connections)
311311
assertThat(pool.connectionCount()).isEqualTo(2)
312312

313313
// Decrease the policy max connections, and check that new connections are created
314-
setPolicy(pool, address, ConnectionPool.AddressPolicy(5, 3))
314+
setPolicy(pool, address, ConnectionPool.AddressPolicy(minimumConcurrentCalls = 5, maximumConcurrentCallsPerConnection = 3))
315315
// fills up the first connect and then removes an unused after
316316
// 5 = 3 + 1 + 1 (three unique connections)
317317
assertThat(pool.connectionCount()).isEqualTo(3)

0 commit comments

Comments
 (0)