Skip to content

Commit 7ee083a

Browse files
committed
Avoid logging HTTP message version where it can be a hint, not an actual protocol version
1 parent 8c934ba commit 7ee083a

File tree

9 files changed

+18
-29
lines changed

9 files changed

+18
-29
lines changed

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.apache.hc.core5.http.HttpResponse;
7171
import org.apache.hc.core5.http.HttpStatus;
7272
import org.apache.hc.core5.http.impl.BasicEntityDetails;
73-
import org.apache.hc.core5.http.message.RequestLine;
7473
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
7574
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
7675
import org.apache.hc.core5.http.nio.CapacityChannel;
@@ -242,7 +241,7 @@ public void doExecute(
242241
final CancellableDependency operation = scope.cancellableDependency;
243242

244243
if (LOG.isDebugEnabled()) {
245-
LOG.debug("{} request via cache: {}", exchangeId, new RequestLine(request));
244+
LOG.debug("{} request via cache: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
246245
}
247246

248247
context.setCacheResponseStatus(CacheResponseStatus.CACHE_MISS);
@@ -727,7 +726,7 @@ private void handleCacheHit(
727726
final String exchangeId = scope.exchangeId;
728727

729728
if (LOG.isDebugEnabled()) {
730-
LOG.debug("{} cache hit: {}", exchangeId, new RequestLine(request));
729+
LOG.debug("{} cache hit: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
731730
}
732731

733732
context.setCacheResponseStatus(CacheResponseStatus.CACHE_HIT);
@@ -1150,7 +1149,7 @@ private void handleCacheMiss(
11501149
final String exchangeId = scope.exchangeId;
11511150

11521151
if (LOG.isDebugEnabled()) {
1153-
LOG.debug("{} cache miss: {}", exchangeId, new RequestLine(request));
1152+
LOG.debug("{} cache miss: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
11541153
}
11551154
cacheMisses.getAndIncrement();
11561155

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpAsyncCache.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
import org.apache.hc.core5.http.HttpResponse;
5858
import org.apache.hc.core5.http.HttpStatus;
5959
import org.apache.hc.core5.http.Method;
60-
import org.apache.hc.core5.http.message.RequestLine;
61-
import org.apache.hc.core5.http.message.StatusLine;
6260
import org.apache.hc.core5.util.ByteArrayBuffer;
6361
import org.slf4j.Logger;
6462
import org.slf4j.LoggerFactory;
@@ -547,7 +545,8 @@ public void cancelled() {
547545
public Cancellable evictInvalidatedEntries(
548546
final HttpHost host, final HttpRequest request, final HttpResponse response, final FutureCallback<Boolean> callback) {
549547
if (LOG.isDebugEnabled()) {
550-
LOG.debug("Flush cache entries invalidated by exchange: {}; {} -> {}", host, new RequestLine(request), new StatusLine(response));
548+
LOG.debug("Flush cache entries invalidated by exchange: {}; {} {} -> {}",
549+
host, request.getMethod(), request.getRequestUri(), response.getCode());
551550
}
552551
final int status = response.getCode();
553552
if (status >= HttpStatus.SC_SUCCESS && status < HttpStatus.SC_CLIENT_ERROR &&

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicHttpCache.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
import org.apache.hc.core5.http.HttpResponse;
5151
import org.apache.hc.core5.http.HttpStatus;
5252
import org.apache.hc.core5.http.Method;
53-
import org.apache.hc.core5.http.message.RequestLine;
54-
import org.apache.hc.core5.http.message.StatusLine;
5553
import org.apache.hc.core5.util.ByteArrayBuffer;
5654
import org.slf4j.Logger;
5755
import org.slf4j.LoggerFactory;
@@ -343,7 +341,8 @@ private void evict(final String rootKey, final HttpResponse response) {
343341
@Override
344342
public void evictInvalidatedEntries(final HttpHost host, final HttpRequest request, final HttpResponse response) {
345343
if (LOG.isDebugEnabled()) {
346-
LOG.debug("Evict cache entries invalidated by exchange: {}; {} -> {}", host, new RequestLine(request), new StatusLine(response));
344+
LOG.debug("Evict cache entries invalidated by exchange: {}; {} {} -> {}",
345+
host, request.getMethod(), request.getRequestUri(), response.getCode());
347346
}
348347
final int status = response.getCode();
349348
if (status >= HttpStatus.SC_SUCCESS && status < HttpStatus.SC_CLIENT_ERROR &&

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import org.apache.hc.core5.http.io.entity.StringEntity;
6666
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
6767
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
68-
import org.apache.hc.core5.http.message.RequestLine;
6968
import org.apache.hc.core5.net.URIAuthority;
7069
import org.apache.hc.core5.util.Args;
7170
import org.apache.hc.core5.util.ByteArrayBuffer;
@@ -147,7 +146,7 @@ ClassicHttpResponse doExecute(
147146
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
148147

149148
if (LOG.isDebugEnabled()) {
150-
LOG.debug("{} request via cache: {}", exchangeId, new RequestLine(request));
149+
LOG.debug("{} request via cache: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
151150
}
152151

153152
context.setCacheResponseStatus(CacheResponseStatus.CACHE_MISS);
@@ -247,7 +246,7 @@ private ClassicHttpResponse handleCacheHit(
247246
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
248247

249248
if (LOG.isDebugEnabled()) {
250-
LOG.debug("{} cache hit: {}", exchangeId, new RequestLine(request));
249+
LOG.debug("{} cache hit: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
251250
}
252251

253252
context.setCacheResponseStatus(CacheResponseStatus.CACHE_HIT);
@@ -571,7 +570,7 @@ private ClassicHttpResponse handleCacheMiss(
571570
final String exchangeId = scope.exchangeId;
572571

573572
if (LOG.isDebugEnabled()) {
574-
LOG.debug("{} cache miss: {}", exchangeId, new RequestLine(request));
573+
LOG.debug("{} cache miss: {} {}", exchangeId, request.getMethod(), request.getRequestUri());
575574
}
576575
cacheMisses.getAndIncrement();
577576

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/Result.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
import org.apache.hc.core5.http.HttpRequest;
3030
import org.apache.hc.core5.http.HttpResponse;
31-
import org.apache.hc.core5.http.message.RequestLine;
32-
import org.apache.hc.core5.http.message.StatusLine;
3331

3432
public final class Result<T> {
3533

@@ -65,13 +63,13 @@ public boolean isOK() {
6563
@Override
6664
public String toString() {
6765
final StringBuilder buf = new StringBuilder();
68-
buf.append(new RequestLine(request));
66+
buf.append(request.getMethod()).append(" ").append(request.getRequestUri());
6967
buf.append(" -> ");
7068
if (exception != null) {
7169
buf.append("NOK: ").append(exception);
7270
} else {
7371
if (response != null) {
74-
buf.append("OK: ").append(new StatusLine(response));
72+
buf.append("OK: ").append(response.getCode());
7573
}
7674
}
7775
return buf.toString();

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncMainClientExec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import org.apache.hc.core5.http.HttpException;
4848
import org.apache.hc.core5.http.HttpRequest;
4949
import org.apache.hc.core5.http.HttpResponse;
50-
import org.apache.hc.core5.http.message.RequestLine;
5150
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
5251
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
5352
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
@@ -93,7 +92,7 @@ public void execute(
9392
final AsyncExecRuntime execRuntime = scope.execRuntime;
9493

9594
if (LOG.isDebugEnabled()) {
96-
LOG.debug("{} executing {}", exchangeId, new RequestLine(request));
95+
LOG.debug("{} executing {} {}", exchangeId, request.getMethod(), request.getRequestUri());
9796
}
9897

9998
final AsyncClientExchangeHandler internalExchangeHandler = new AsyncClientExchangeHandler() {

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncMainClientExec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
import org.apache.hc.core5.http.HttpStatus;
5656
import org.apache.hc.core5.http.ProtocolException;
5757
import org.apache.hc.core5.http.ProtocolVersion;
58-
import org.apache.hc.core5.http.message.RequestLine;
5958
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
6059
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
6160
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
@@ -110,7 +109,7 @@ public void execute(
110109
final AsyncExecRuntime execRuntime = scope.execRuntime;
111110

112111
if (LOG.isDebugEnabled()) {
113-
LOG.debug("{} executing {}", exchangeId, new RequestLine(request));
112+
LOG.debug("{} executing {} {}", exchangeId, request.getMethod(), request.getRequestUri());
114113
}
115114

116115
final AtomicInteger messageCountDown = new AtomicInteger(2);

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/LoggingAsyncClientExchangeHandler.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.apache.hc.core5.http.Header;
3535
import org.apache.hc.core5.http.HttpException;
3636
import org.apache.hc.core5.http.HttpResponse;
37-
import org.apache.hc.core5.http.message.RequestLine;
38-
import org.apache.hc.core5.http.message.StatusLine;
3937
import org.apache.hc.core5.http.nio.AsyncClientExchangeHandler;
4038
import org.apache.hc.core5.http.nio.CapacityChannel;
4139
import org.apache.hc.core5.http.nio.DataStreamChannel;
@@ -70,7 +68,7 @@ public void releaseResources() {
7068
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
7169
handler.produceRequest((request, entityDetails, context1) -> {
7270
if (log.isDebugEnabled()) {
73-
log.debug("{} send request {}, {}", exchangeId, new RequestLine(request),
71+
log.debug("{} send request {} {}, {}", exchangeId, request.getMethod(), request.getRequestUri(),
7472
entityDetails != null ? "entity len " + entityDetails.getContentLength() : "null entity");
7573
}
7674
channel.sendRequest(request, entityDetails, context1);
@@ -126,7 +124,7 @@ public void consumeInformation(
126124
final HttpResponse response,
127125
final HttpContext context) throws HttpException, IOException {
128126
if (log.isDebugEnabled()) {
129-
log.debug("{}: information response {}", exchangeId, new StatusLine(response));
127+
log.debug("{}: information response {}", exchangeId, response.getCode());
130128
}
131129
handler.consumeInformation(response, context);
132130
}
@@ -137,7 +135,7 @@ public void consumeResponse(
137135
final EntityDetails entityDetails,
138136
final HttpContext context) throws HttpException, IOException {
139137
if (log.isDebugEnabled()) {
140-
log.debug("{}: consume response {}, {}", exchangeId, new StatusLine(response), entityDetails != null ? "entity len " + entityDetails.getContentLength() : " null entity");
138+
log.debug("{}: consume response {}, {}", exchangeId, response.getCode(), entityDetails != null ? "entity len " + entityDetails.getContentLength() : " null entity");
141139
}
142140
handler.consumeResponse(response, entityDetails, context);
143141
}

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/MainClientExec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.apache.hc.core5.http.HttpStatus;
5252
import org.apache.hc.core5.http.ProtocolException;
5353
import org.apache.hc.core5.http.ProtocolVersion;
54-
import org.apache.hc.core5.http.message.RequestLine;
5554
import org.apache.hc.core5.http.protocol.HttpProcessor;
5655
import org.apache.hc.core5.io.CloseMode;
5756
import org.apache.hc.core5.util.Args;
@@ -109,7 +108,7 @@ public ClassicHttpResponse execute(
109108
final ExecRuntime execRuntime = scope.execRuntime;
110109

111110
if (LOG.isDebugEnabled()) {
112-
LOG.debug("{} executing {}", exchangeId, new RequestLine(request));
111+
LOG.debug("{} executing {} {}", exchangeId, request.getMethod(), request.getRequestUri());
113112
}
114113
try {
115114
// Run request protocol interceptors

0 commit comments

Comments
 (0)