mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +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();
|
||||
URI url = clientRequest.url();
|
||||
|
||||
return this.connector
|
||||
.connect(httpMethod, url, httpRequest -> clientRequest.writeTo(httpRequest, this.strategies))
|
||||
.doOnRequest(n -> logRequest(clientRequest))
|
||||
.doOnCancel(() -> logger.debug(clientRequest.logPrefix() + "Cancel signal (to close connection)"))
|
||||
Mono<ClientHttpResponse> responseMono = this.connector
|
||||
.connect(httpMethod, url, httpRequest -> clientRequest.writeTo(httpRequest, this.strategies));
|
||||
if (logger.isDebugEnabled()) {
|
||||
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))
|
||||
.map(httpResponse -> {
|
||||
String logPrefix = getLogPrefix(clientRequest, httpResponse);
|
||||
|
||||
Reference in New Issue
Block a user