From 56688ab36130aa9b08c456a2ef90287337c39a74 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 16 Sep 2023 18:09:18 +0200 Subject: [PATCH] Polish contribution See gh-31244 --- .../org/springframework/web/servlet/DispatcherServlet.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 3151ed583b32..109fd4ca5a41 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -1018,11 +1018,14 @@ else if (isEnableLoggingRequestDetails()) { if (traceOn) { List values = Collections.list(request.getHeaderNames()); - String headers = values.isEmpty() ? "" : "masked"; + String headers; if (isEnableLoggingRequestDetails()) { headers = values.stream().map(name -> name + ":" + Collections.list(request.getHeaders(name))) .collect(Collectors.joining(", ")); } + else { + headers = (!values.isEmpty() ? "masked" : ""); + } return message + ", headers={" + headers + "} in DispatcherServlet '" + getServletName() + "'"; } else {