Fixes #5165 - Wrong messagesIn count for HttpClient.

Now incrementing inMessages only when the response is complete.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-08-18 10:31:36 +02:00
parent ff3ebeff54
commit 0646e4d0b5
2 changed files with 11 additions and 4 deletions

View File

@ -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()

View File

@ -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()
{