Browse Source

Extract "server.ports" hardcoding into a constant

See gh-38029
pull/38065/head
DevSeoRex 2 years ago committed by Moritz Halbritter
parent
commit
01e2f70c73
  1. 5
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java

5
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/rsocket/context/RSocketPortInfoApplicationContextInitializer.java

@ -54,6 +54,7 @@ public class RSocketPortInfoApplicationContextInitializer @@ -54,6 +54,7 @@ public class RSocketPortInfoApplicationContextInitializer
private static class Listener implements ApplicationListener<RSocketServerInitializedEvent> {
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 @@ -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);

Loading…
Cancel
Save