mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +03:00
Never put pooled connections in the result queue (#7154)
In a race this could cause us to prefer a new connection over a pooled connection, which violates our invariant that pooled connections are always used if they're found. Closes: https://github.com/square/okhttp/issues/7152
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package okhttp3.internal.concurrent
|
||||
|
||||
import okhttp3.OkHttpClient
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import java.io.Closeable
|
||||
import java.util.AbstractQueue
|
||||
import java.util.concurrent.BlockingQueue
|
||||
@@ -23,8 +25,6 @@ import java.util.concurrent.Semaphore
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.logging.Logger
|
||||
import okhttp3.OkHttpClient
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
|
||||
/**
|
||||
* Runs a [TaskRunner] in a controlled environment so that everything is sequential and
|
||||
@@ -266,6 +266,14 @@ class TaskFaker : Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Artificially stall until manually resumed by the test thread with [runTasks]. Use this to
|
||||
* simulate races in tasks that doesn't have a deterministic sequence.
|
||||
*/
|
||||
fun yield() {
|
||||
stall()
|
||||
}
|
||||
|
||||
/**
|
||||
* This blocking queue hooks into a fake clock rather than using regular JVM timing for functions
|
||||
* like [poll]. It is only usable within task faker tasks.
|
||||
|
Reference in New Issue
Block a user