You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the server is unreachable and isn't able to answer to the connect request. Using Thread.interrupt() doesn't cancel the call and only unblock after the connectTimeout
property has passed.
Expected behaviour
I Exptect Thread.interrupt() to have the same behaviour as call.cancel() -> Cancel the call even when stuck at the connecting state.
Client information
OS : Unix
OKHttp Version : 4.9.0
JDK : AdoptOpenJDK 11
Step to reproduce
Make a call that would result in a connectTimeout and try to interrupt it with Thread.interrupt()
I don't think we are against improving our handling here, I think it's complicated because interrupts in frameworks/containers are awkward to get right for everyone, and it's unpredictable on different devices (Android vs JDK) and versions. Or with different socket implementations like Conscrypt.
If you can add a PR and clean maintainable fix it might be viable, but at the moment it's been easier to say that we expect clients to use the public API over assuming that interrupts are exactly equivalent to a cancel call.
Describe the bug
When the server is unreachable and isn't able to answer to the connect request. Using
Thread.interrupt()
doesn't cancel the call and only unblock after theconnectTimeout
property has passed.
Expected behaviour
I Exptect
Thread.interrupt()
to have the same behaviour ascall.cancel()
-> Cancel the call even when stuck at the connecting state.Client information
OS : Unix
OKHttp Version : 4.9.0
JDK : AdoptOpenJDK 11
Step to reproduce
Make a call that would result in a
connectTimeout
and try to interrupt it withThread.interrupt()
Here is a java test (using assertJ)
The test is passing using
call.cancel()
and failing usingThread.interrupt()
Here is a unit test that can be placed in CancelTest.kt
Test using the
H2
ConnectionType will fail as it's not a valid shcheme.Tests using
call.cancel()
will succeed.Tests using
Thread.interrupt()
will fail after the connectTimeout delay.The Thrown exception is
instead of
with the
call.cancel()
methodThe text was updated successfully, but these errors were encountered: