mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +00:00
Skip logging operators in DefaultExchangeFunction when possible
Prior to this commit, `DefaultExchangeFunction.exchange` added logging operations within `doOnRequest`/`doOnCancel` operators unconditionally, which costs two subscriber wrappers per request even though the log message construction itself is already guarded lazily. This commit gates the operators on `isDebugEnabled()`, checked per exchange so runtime log level changes are still honored. Signed-off-by: samlightfoot <samueldlightfoot@gmail.com>
This commit is contained in:
committed by
Brian Clozel
parent
4b5c92703c
commit
595c246cce
+8
-4
@@ -99,10 +99,14 @@ public abstract class ExchangeFunctions {
|
|||||||
HttpMethod httpMethod = clientRequest.method();
|
HttpMethod httpMethod = clientRequest.method();
|
||||||
URI url = clientRequest.url();
|
URI url = clientRequest.url();
|
||||||
|
|
||||||
return this.connector
|
Mono<ClientHttpResponse> responseMono = this.connector
|
||||||
.connect(httpMethod, url, httpRequest -> clientRequest.writeTo(httpRequest, this.strategies))
|
.connect(httpMethod, url, httpRequest -> clientRequest.writeTo(httpRequest, this.strategies));
|
||||||
.doOnRequest(n -> logRequest(clientRequest))
|
if (logger.isDebugEnabled()) {
|
||||||
.doOnCancel(() -> logger.debug(clientRequest.logPrefix() + "Cancel signal (to close connection)"))
|
responseMono = responseMono
|
||||||
|
.doOnRequest(n -> logRequest(clientRequest))
|
||||||
|
.doOnCancel(() -> logger.debug(clientRequest.logPrefix() + "Cancel signal (to close connection)"));
|
||||||
|
}
|
||||||
|
return responseMono
|
||||||
.onErrorResume(WebClientUtils.WRAP_EXCEPTION_PREDICATE, t -> wrapException(t, clientRequest))
|
.onErrorResume(WebClientUtils.WRAP_EXCEPTION_PREDICATE, t -> wrapException(t, clientRequest))
|
||||||
.map(httpResponse -> {
|
.map(httpResponse -> {
|
||||||
String logPrefix = getLogPrefix(clientRequest, httpResponse);
|
String logPrefix = getLogPrefix(clientRequest, httpResponse);
|
||||||
|
|||||||
Reference in New Issue
Block a user