Skip to content

Commit

Permalink
Fixes #5165 - Wrong messagesIn count for HttpClient.
Browse files Browse the repository at this point in the history
Now incrementing inMessages only when the response is complete.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Aug 18, 2020
1 parent ff3ebef commit 0646e4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -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)
Expand Down Expand Up @@ -129,7 +128,6 @@ public Result exchangeTerminating(HttpExchange exchange, Result result)

public void receive()
{
inMessages.increment();
receiver.receive();
}

Expand Down Expand Up @@ -185,7 +183,7 @@ else if (sender.isShutdown())

protected long getMessagesIn()
{
return inMessages.longValue();
return receiver.getMessagesIn();
}

protected long getMessagesOut()
Expand Down
Expand Up @@ -20,6 +20,7 @@

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;
Expand All @@ -40,6 +41,7 @@

public class HttpReceiverOverHTTP extends HttpReceiver implements HttpParser.ResponseHandler
{
private final LongAdder inMessages = new LongAdder();
private final HttpParser parser;
private RetainableByteBuffer networkBuffer;
private boolean shutdown;
Expand Down Expand Up @@ -333,9 +335,11 @@ public boolean messageComplete()
return false;

int status = exchange.getResponse().getStatus();

if (status != HttpStatus.CONTINUE_100)
{
inMessages.increment();
complete = true;
}

return !responseSuccess(exchange);
}
Expand Down Expand Up @@ -376,6 +380,11 @@ private void failAndClose(Throwable failure)
getHttpConnection().close(failure);
}

long getMessagesIn()
{
return inMessages.longValue();
}

@Override
public String toString()
{
Expand Down

0 comments on commit 0646e4d

Please sign in to comment.