From c402f8d5fa0736c2379ad0a724f1907170c71b7e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Mon, 11 Sep 2017 17:03:22 +0200 Subject: [PATCH] Fixed test after #1804. --- .../jetty/client/HttpResponseAbortTest.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java index fd9476e85be..1dca5d058f6 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpResponseAbortTest.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.client; import java.io.IOException; import java.io.OutputStream; +import java.nio.ByteBuffer; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -28,6 +29,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.util.DeferredContentProvider; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; @@ -156,28 +158,18 @@ public class HttpResponseAbortTest extends AbstractHttpClientServerTest } }); - final CountDownLatch abortLatch = new CountDownLatch(1); + final DeferredContentProvider contentProvider = new DeferredContentProvider(ByteBuffer.allocate(1)); final AtomicInteger completes = new AtomicInteger(); final CountDownLatch completeLatch = new CountDownLatch(1); client.newRequest("localhost", connector.getLocalPort()) .scheme(scheme) - .onRequestSuccess(request -> - { - try - { - abortLatch.await(5, TimeUnit.SECONDS); - } - catch (InterruptedException x) - { - x.printStackTrace(); - } - }) + .content(contentProvider) .onResponseContent((response, content) -> { try { response.abort(new Exception()); - abortLatch.countDown(); + contentProvider.close(); // Delay to let the request side to finish its processing. Thread.sleep(1000); }