From 0646e4d0b5138fc02cc3af8c04ad4c499c70e0a3 Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 18 Aug 2020 10:31:36 +0200 Subject: [PATCH] Fixes #5165 - Wrong messagesIn count for HttpClient. Now incrementing inMessages only when the response is complete. Signed-off-by: Simone Bordet --- .../jetty/client/http/HttpChannelOverHTTP.java | 4 +--- .../jetty/client/http/HttpReceiverOverHTTP.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java index fa358b0d037..3d6904b1488 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpChannelOverHTTP.java @@ -40,7 +40,6 @@ public class HttpChannelOverHTTP extends HttpChannel private final HttpConnectionOverHTTP connection; private final HttpSenderOverHTTP sender; private final HttpReceiverOverHTTP receiver; - private final LongAdder inMessages = new LongAdder(); private final LongAdder outMessages = new LongAdder(); public HttpChannelOverHTTP(HttpConnectionOverHTTP connection) @@ -129,7 +128,6 @@ public class HttpChannelOverHTTP extends HttpChannel public void receive() { - inMessages.increment(); receiver.receive(); } @@ -185,7 +183,7 @@ public class HttpChannelOverHTTP extends HttpChannel protected long getMessagesIn() { - return inMessages.longValue(); + return receiver.getMessagesIn(); } protected long getMessagesOut() diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java index e5bf9eec51b..b6350461cd2 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/http/HttpReceiverOverHTTP.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.client.http; import java.io.EOFException; import java.nio.ByteBuffer; +import java.util.concurrent.atomic.LongAdder; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; @@ -40,6 +41,7 @@ import org.eclipse.jetty.util.Callback; public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.ResponseHandler { + private final LongAdder inMessages = new LongAdder(); private final HttpParser parser; private RetainableByteBuffer networkBuffer; private boolean shutdown; @@ -333,9 +335,11 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res return false; int status = exchange.getResponse().getStatus(); - if (status != HttpStatus.CONTINUE_100) + { + inMessages.increment(); complete = true; + } return !responseSuccess(exchange); } @@ -376,6 +380,11 @@ public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.Res getHttpConnection().close(failure); } + long getMessagesIn() + { + return inMessages.longValue(); + } + @Override public String toString() {