From 228600caf509e02be646415db95048126452e8ac Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 2 Jul 2014 15:08:06 +1000 Subject: [PATCH] fixed race in HttpReceiverOverHTTPTest --- .../main/java/org/eclipse/jetty/client/HttpReceiver.java | 3 +++ .../jetty/client/http/HttpReceiverOverHTTPTest.java | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java index 7e163caab04..0f5da04d968 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpReceiver.java @@ -301,6 +301,9 @@ public abstract class HttpReceiver if (decoder != null) { buffer = decoder.decode(buffer); + + // TODO If the decoder consumes all the content, should we return here? + if (LOG.isDebugEnabled()) LOG.debug("Response content decoded ({}) {}{}{}", decoder, response, System.lineSeparator(), BufferUtil.toDetailString(buffer)); } diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java index 0be2b913973..7ae69ea92df 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTPTest.java @@ -42,6 +42,7 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.io.ByteArrayEndPoint; import org.eclipse.jetty.toolchain.test.TestTracker; +import org.eclipse.jetty.util.BufferUtil; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -230,8 +231,12 @@ public class HttpReceiverOverHTTPTest @Override public void onContent(Response response, ByteBuffer content) { + boolean hadRemaining=content.hasRemaining(); super.onContent(response, content); - latch.countDown(); + + // TODO gzip decoding can pass on empty chunks. Currently ignoring them here, but could be done at the decoder??? + if (hadRemaining) // Ignore empty chunks + latch.countDown(); } }; HttpExchange exchange = new HttpExchange(destination, request, Collections.singletonList(listener));