Skip to content

Commit f9d8367

Browse files
committed
Exclude URL query from checkpoint in DefaultWebClient
Closes gh-29148
1 parent 09b19d7 commit f9d8367

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClient.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.web.reactive.function.client;
1818

1919
import java.net.URI;
20+
import java.net.URISyntaxException;
2021
import java.nio.charset.Charset;
2122
import java.time.ZonedDateTime;
2223
import java.util.ArrayList;
@@ -49,6 +50,7 @@
4950
import org.springframework.util.CollectionUtils;
5051
import org.springframework.util.LinkedMultiValueMap;
5152
import org.springframework.util.MultiValueMap;
53+
import org.springframework.util.StringUtils;
5254
import org.springframework.web.reactive.function.BodyExtractor;
5355
import org.springframework.web.reactive.function.BodyInserter;
5456
import org.springframework.web.reactive.function.BodyInserters;
@@ -667,10 +669,22 @@ private <T> Mono<T> applyStatusHandlers(ClientResponse response) {
667669
}
668670

669671
private <T> Mono<T> insertCheckpoint(Mono<T> result, int statusCode, HttpRequest request) {
670-
String httpMethod = request.getMethodValue();
672+
String method = request.getMethodValue();
673+
URI uri = getUriToLog(request);
674+
return result.checkpoint(statusCode + " from " + method + " " + uri + " [DefaultWebClient]");
675+
}
676+
677+
private static URI getUriToLog(HttpRequest request) {
671678
URI uri = request.getURI();
672-
String description = statusCode + " from " + httpMethod + " " + uri + " [DefaultWebClient]";
673-
return result.checkpoint(description);
679+
if (StringUtils.hasText(uri.getQuery())) {
680+
try {
681+
uri = new URI(uri.getScheme(), uri.getHost(), uri.getPath(), null);
682+
}
683+
catch (URISyntaxException ex) {
684+
// ignore
685+
}
686+
}
687+
return uri;
674688
}
675689

676690

0 commit comments

Comments
 (0)