460905 - Make sure TimeoutCompleteListener is cancelled if the request cannot be sent.

This commit is contained in:
Simone Bordet 2015-02-26 12:25:42 +01:00
parent d5a6ad2345
commit 008b03ac78
2 changed files with 17 additions and 8 deletions

View File

@ -683,6 +683,7 @@ public class HttpRequest implements Request
// can't even start sending the request.
if (timeoutListener != null)
timeoutListener.cancel();
throw x;
}
}

View File

@ -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);