From 33953823fc70e55d73e1c44f81f42899687bdce2 Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Mon, 6 Dec 2021 16:12:34 -0600 Subject: [PATCH] Replace usage of deprecated Spring Framework methods See gh-28642 --- .../autoconfigure/web/server/ManagementServerProperties.java | 5 ++++- .../boot/autoconfigure/web/ServerProperties.java | 5 ++++- .../boot/autoconfigure/web/reactive/WebFluxProperties.java | 5 ++++- .../boot/context/logging/LoggingApplicationListener.java | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java index 87a1f51cb3..e476398f54 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java @@ -102,7 +102,10 @@ public class ManagementServerProperties { } private String cleanBasePath(String basePath) { - String candidate = StringUtils.trimWhitespace(basePath); + String candidate = null; + if (StringUtils.hasLength(basePath)) { + candidate = basePath.strip(); + } if (StringUtils.hasText(candidate)) { if (!candidate.startsWith("/")) { candidate = "/" + candidate; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 367934c40e..09975bb2d3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -262,7 +262,10 @@ public class ServerProperties { } private String cleanContextPath(String contextPath) { - String candidate = StringUtils.trimWhitespace(contextPath); + String candidate = null; + if (StringUtils.hasLength(contextPath)) { + candidate = contextPath.strip(); + } if (StringUtils.hasText(candidate) && candidate.endsWith("/")) { return candidate.substring(0, candidate.length() - 1); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java index 001a902cc6..990b9f1fa6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxProperties.java @@ -52,7 +52,10 @@ public class WebFluxProperties { } private String cleanBasePath(String basePath) { - String candidate = StringUtils.trimWhitespace(basePath); + String candidate = null; + if (StringUtils.hasLength(basePath)) { + candidate = basePath.strip(); + } if (StringUtils.hasText(candidate)) { if (!candidate.startsWith("/")) { candidate = "/" + candidate; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java index a2bb0ffc3a..ba1b25c982 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java @@ -306,7 +306,10 @@ public class LoggingApplicationListener implements GenericApplicationListener { } private void initializeSystem(ConfigurableEnvironment environment, LoggingSystem system, LogFile logFile) { - String logConfig = StringUtils.trimWhitespace(environment.getProperty(CONFIG_PROPERTY)); + String logConfig = environment.getProperty(CONFIG_PROPERTY); + if (StringUtils.hasLength(logConfig)) { + logConfig = logConfig.strip(); + } try { LoggingInitializationContext initializationContext = new LoggingInitializationContext(environment); if (ignoreLogConfig(logConfig)) {