From 09b6730f3d89b55819ea9bea66314269b7cc4fd9 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 13 Dec 2019 10:59:33 +0100 Subject: [PATCH] Expose logPrefix in ClientResponse This commit exposes the logPrefix field in the ClientResponse interface. Closes gh-24146 --- .../reactive/function/client/ClientResponse.java | 13 +++++++++++++ .../function/client/DefaultClientResponse.java | 5 +++++ .../client/support/ClientResponseWrapper.java | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 5c6eaa0cf196..6c5bf5b79579 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -204,6 +204,19 @@ public interface ClientResponse { */ Mono createException(); + /** + * Return a log message prefix to use to correlate messages for this response. + * The prefix is based on the {@linkplain ClientRequest#logPrefix() client + * log prefix}, which itself is based on the value of the request attribute + * {@link ClientRequest#LOG_ID_ATTRIBUTE} along with some extra formatting + * so that the prefix can be conveniently prepended with no further + * formatting no separators required. + * @return the log message prefix or an empty String if the + * {@link ClientRequest#LOG_ID_ATTRIBUTE} was not set. + * @since 5.2.3 + */ + String logPrefix(); + // Static builder methods diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java index 11d64b9f7f6e..c148c80ee07b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java @@ -225,6 +225,11 @@ public Mono createException() { }); } + @Override + public String logPrefix() { + return this.logPrefix; + } + // Used by DefaultClientResponseBuilder HttpRequest request() { return this.requestSupplier.get(); diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java index 8c98310ce520..3b558eeee308 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapper.java @@ -153,6 +153,11 @@ public Mono createException() { return this.delegate.createException(); } + @Override + public String logPrefix() { + return this.delegate.logPrefix(); + } + /** * Implementation of the {@code Headers} interface that can be subclassed * to adapt the headers in a