diff --git a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java index 58452512ccd..71d1d38b672 100644 --- a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java +++ b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/AbstractHttpClientServerTest.java @@ -25,6 +25,7 @@ import org.eclipse.jetty.client.HttpClientTransport; import org.eclipse.jetty.client.LeakTrackingConnectionPool; import org.eclipse.jetty.fcgi.client.http.HttpClientTransportOverFCGI; import org.eclipse.jetty.http.HttpScheme; +import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.LeakTrackingByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.server.Handler; @@ -45,7 +46,7 @@ public abstract class AbstractHttpClientServerTest @Rule public final TestTracker tracker = new TestTracker(); private LeakTrackingByteBufferPool serverBufferPool; - private LeakTrackingByteBufferPool clientBufferPool; + protected ByteBufferPool clientBufferPool; private final AtomicLong connectionLeaks = new AtomicLong(); protected Server server; protected ServerConnector connector; @@ -80,7 +81,8 @@ public abstract class AbstractHttpClientServerTest }); client = new HttpClient(transport, null); client.setExecutor(executor); - clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged()); + if (clientBufferPool == null) + clientBufferPool = new LeakTrackingByteBufferPool(new MappedByteBufferPool.Tagged()); client.setByteBufferPool(clientBufferPool); client.start(); } @@ -94,9 +96,13 @@ public abstract class AbstractHttpClientServerTest assertThat("Server BufferPool - leaked releases", serverBufferPool.getLeakedReleases(), Matchers.is(0L)); assertThat("Server BufferPool - unreleased", serverBufferPool.getLeakedResources(), Matchers.is(0L)); - assertThat("Client BufferPool - leaked acquires", clientBufferPool.getLeakedAcquires(), Matchers.is(0L)); - assertThat("Client BufferPool - leaked releases", clientBufferPool.getLeakedReleases(), Matchers.is(0L)); - assertThat("Client BufferPool - unreleased", clientBufferPool.getLeakedResources(), Matchers.is(0L)); + if (clientBufferPool instanceof LeakTrackingByteBufferPool) + { + LeakTrackingByteBufferPool pool = (LeakTrackingByteBufferPool)clientBufferPool; + assertThat("Client BufferPool - leaked acquires", pool.getLeakedAcquires(), Matchers.is(0L)); + assertThat("Client BufferPool - leaked releases", pool.getLeakedReleases(), Matchers.is(0L)); + assertThat("Client BufferPool - unreleased", pool.getLeakedResources(), Matchers.is(0L)); + } assertThat("Connection Leaks", connectionLeaks.get(), Matchers.is(0L)); diff --git a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java index 972c7dc06e0..6baf3b69242 100644 --- a/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java +++ b/jetty-fcgi/fcgi-server/src/test/java/org/eclipse/jetty/fcgi/server/HttpClientTest.java @@ -46,6 +46,7 @@ import org.eclipse.jetty.client.util.BytesContentProvider; import org.eclipse.jetty.client.util.DeferredContentProvider; import org.eclipse.jetty.client.util.FutureResponseListener; import org.eclipse.jetty.http.HttpMethod; +import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.IO; import org.eclipse.jetty.toolchain.test.annotation.Slow; @@ -380,6 +381,11 @@ public class HttpClientTest extends AbstractHttpClientServerTest @Test public void testGZIPContentEncoding() throws Exception { + // GZIPContentDecoder returns to application pooled + // buffers, which is fine, but in this test they will + // appear as "leaked", so we use a normal ByteBufferPool. + clientBufferPool = new MappedByteBufferPool.Tagged(); + final byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; start(new AbstractHandler() {