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.
|
// can't even start sending the request.
|
||||||
if (timeoutListener != null)
|
if (timeoutListener != null)
|
||||||
timeoutListener.cancel();
|
timeoutListener.cancel();
|
||||||
|
throw x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,15 +434,23 @@ public class HttpClientTimeoutTest extends AbstractHttpClientServerTest
|
||||||
start(new EmptyServerHandler());
|
start(new EmptyServerHandler());
|
||||||
|
|
||||||
long timeout = 1000;
|
long timeout = 1000;
|
||||||
Request request = client.newRequest("bad_scheme://localhost:" + connector.getLocalPort());
|
Request request = client.newRequest("badscheme://localhost:" + connector.getLocalPort());
|
||||||
request.timeout(timeout, TimeUnit.MILLISECONDS)
|
|
||||||
.send(new Response.CompleteListener()
|
try
|
||||||
{
|
{
|
||||||
@Override
|
request.timeout(timeout, TimeUnit.MILLISECONDS)
|
||||||
public void onComplete(Result result)
|
.send(new Response.CompleteListener()
|
||||||
{
|
{
|
||||||
}
|
@Override
|
||||||
});
|
public void onComplete(Result result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
catch (Exception expected)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
Thread.sleep(2 * timeout);
|
Thread.sleep(2 * timeout);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue