From 01e2f70c7339db01958c234ef96fd24d1f1b98b2 Mon Sep 17 00:00:00 2001 From: DevSeoRex Date: Wed, 25 Oct 2023 21:58:02 +0900 Subject: [PATCH 1/2] Extract "server.ports" hardcoding into a constant See gh-38029 --- .../RSocketPortInfoApplicationContextInitializer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 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 da497d9ab1..1e160726e1 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 @@ -54,6 +54,7 @@ public class RSocketPortInfoApplicationContextInitializer private static class Listener implements ApplicationListener { private static final String PROPERTY_NAME = "local.rsocket.server.port"; + private static final String SERVER_PORTS = "server.ports"; private final ConfigurableApplicationContext applicationContext; @@ -79,9 +80,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(SERVER_PORTS); if (source == null) { - source = new MapPropertySource("server.ports", new HashMap<>()); + source = new MapPropertySource(SERVER_PORTS, new HashMap<>()); sources.addFirst(source); } setPortProperty(port, source); From 8095c2a94b720ebb712bb3eb5c1f71f4c733a3d4 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Thu, 26 Oct 2023 14:35:02 +0200 Subject: [PATCH 2/2] Polish "Extract "server.ports" hardcoding into a constant" See gh-38029 --- .../context/RSocketPortInfoApplicationContextInitializer.java | 1 + 1 file changed, 1 insertion(+) 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 1e160726e1..7a3fed4a02 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 @@ -54,6 +54,7 @@ public class RSocketPortInfoApplicationContextInitializer private static class Listener implements ApplicationListener { private static final String PROPERTY_NAME = "local.rsocket.server.port"; + private static final String SERVER_PORTS = "server.ports"; private final ConfigurableApplicationContext applicationContext;