Merged branch 'jetty-9.2.x' into 'jetty-9.3.x'.
This commit is contained in:
commit
04bb4af12c
|
@ -152,6 +152,9 @@ public abstract class PoolingHttpDestination<C extends Connection> extends HttpD
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Aborted before processing {}: {}", exchange, cause);
|
LOG.debug("Aborted before processing {}: {}", exchange, cause);
|
||||||
|
// Won't use this connection, release it back.
|
||||||
|
if (!connectionPool.release(connection))
|
||||||
|
connection.close();
|
||||||
// It may happen that the request is aborted before the exchange
|
// It may happen that the request is aborted before the exchange
|
||||||
// is created. Aborting the exchange a second time will result in
|
// is created. Aborting the exchange a second time will result in
|
||||||
// a no-operation, so we just abort here to cover that edge case.
|
// a no-operation, so we just abort here to cover that edge case.
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -47,6 +48,33 @@ public class HttpRequestAbortTest extends AbstractHttpClientServerTest
|
||||||
super(sslContextFactory);
|
super(sslContextFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAbortBeforeQueued() throws Exception
|
||||||
|
{
|
||||||
|
start(new EmptyServerHandler());
|
||||||
|
|
||||||
|
Exception failure = new Exception("oops");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Request request = client.newRequest("localhost", connector.getLocalPort())
|
||||||
|
.scheme(scheme)
|
||||||
|
.timeout(5, TimeUnit.SECONDS);
|
||||||
|
request.abort(failure);
|
||||||
|
request.send();
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
catch (ExecutionException x)
|
||||||
|
{
|
||||||
|
Assert.assertSame(failure, x.getCause());
|
||||||
|
// Make sure the pool is in a sane state.
|
||||||
|
HttpDestinationOverHTTP destination = (HttpDestinationOverHTTP)client.getDestination(scheme, "localhost", connector.getLocalPort());
|
||||||
|
ConnectionPool connectionPool = destination.getConnectionPool();
|
||||||
|
Assert.assertEquals(1, connectionPool.getConnectionCount());
|
||||||
|
Assert.assertEquals(0, connectionPool.getActiveConnections().size());
|
||||||
|
Assert.assertEquals(1, connectionPool.getIdleConnections().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbortOnQueued() throws Exception
|
public void testAbortOnQueued() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue