460905 - Make sure TimeoutCompleteListener is cancelled if the request cannot be sent.
This commit is contained in:
parent
d5a6ad2345
commit
008b03ac78
|
@ -683,6 +683,7 @@ public class HttpRequest implements Request
|
|||
// can't even start sending the request.
|
||||
if (timeoutListener != null)
|
||||
timeoutListener.cancel();
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -434,15 +434,23 @@ public class HttpClientTimeoutTest extends AbstractHttpClientServerTest
|
|||
start(new EmptyServerHandler());
|
||||
|
||||
long timeout = 1000;
|
||||
Request request = client.newRequest("bad_scheme://localhost:" + connector.getLocalPort());
|
||||
request.timeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.send(new Response.CompleteListener()
|
||||
{
|
||||
@Override
|
||||
public void onComplete(Result result)
|
||||
Request request = client.newRequest("badscheme://localhost:" + connector.getLocalPort());
|
||||
|
||||
try
|
||||
{
|
||||
request.timeout(timeout, TimeUnit.MILLISECONDS)
|
||||
.send(new Response.CompleteListener()
|
||||
{
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onComplete(Result result)
|
||||
{
|
||||
}
|
||||
});
|
||||
Assert.fail();
|
||||
}
|
||||
catch (Exception expected)
|
||||
{
|
||||
}
|
||||
|
||||
Thread.sleep(2 * timeout);
|
||||
|
||||
|
|
Loading…
Reference in New Issue