Change the way we cope with stale pooled connections.
Previously we'd attempt to detect if a connection was stale by
probing it. This was expensive (it relied on catching a 1-millisecond
read timing out with a SocketTimeoutException), and racy. If the
recycled connection was stale, the application would have to catch
the failure and retry.
The new approach is to try the stale connection directly and to recover
if that connection fails. This is simpler and avoids the isStale
This fixes some flakiness in URLConnectionTest tests like
testServerShutdownOutput and testServerClosesOutput.
5 files changed