From 5ff4a961b131a32c3b6417a4ebd0e55fe8d1a504 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 26 Oct 2023 15:18:02 +0200 Subject: [PATCH] Polish 0fbb1f7890adcc904782de2efb434c34dfe9531c See gh-38029 --- .../RSocketPortInfoApplicationContextInitializer.java | 6 +++--- .../ServerPortInfoApplicationContextInitializer.java | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java index 7a3fed4a02..dd94ba5820 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java @@ -55,7 +55,7 @@ public class RSocketPortInfoApplicationContextInitializer private static final String PROPERTY_NAME = "local.rsocket.server.port"; - private static final String SERVER_PORTS = "server.ports"; + private static final String PROPERTY_SOURCE_NAME = "server.ports"; private final ConfigurableApplicationContext applicationContext; @@ -81,9 +81,9 @@ public class RSocketPortInfoApplicationContextInitializer private void setPortProperty(ConfigurableEnvironment environment, int port) { MutablePropertySources sources = environment.getPropertySources(); - PropertySource source = sources.get(SERVER_PORTS); + PropertySource source = sources.get(PROPERTY_SOURCE_NAME); if (source == null) { - source = new MapPropertySource(SERVER_PORTS, new HashMap<>()); + source = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>()); sources.addFirst(source); } setPortProperty(port, source); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java index 7e3fafe9f4..2ec73ab57a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java @@ -52,6 +52,8 @@ import org.springframework.util.StringUtils; public class ServerPortInfoApplicationContextInitializer implements ApplicationContextInitializer, ApplicationListener { + private static final String PROPERTY_SOURCE_NAME = "server.ports"; + @Override public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.addApplicationListener(this); @@ -80,9 +82,9 @@ public class ServerPortInfoApplicationContextInitializer implements @SuppressWarnings("unchecked") private void setPortProperty(ConfigurableEnvironment environment, String propertyName, int port) { MutablePropertySources sources = environment.getPropertySources(); - PropertySource source = sources.get("server.ports"); + PropertySource source = sources.get(PROPERTY_SOURCE_NAME); if (source == null) { - source = new MapPropertySource("server.ports", new HashMap<>()); + source = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>()); sources.addFirst(source); } ((Map) source.getSource()).put(propertyName, port);