Skip to content

Commit a437028

Browse files
committed
Resolve Reviews
1 parent 8468cce commit a437028

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ private void setDriverClass(ComboPooledDataSource dataSource, String driverClass
698698
*/
699699
private static class SimpleDataSourceProperties extends MappedDataSourceProperties<SimpleDriverDataSource> {
700700

701+
@SuppressWarnings("unchecked")
701702
SimpleDataSourceProperties() {
702703
add(DataSourceProperty.URL, SimpleDriverDataSource::getUrl, SimpleDriverDataSource::setUrl);
703704
add(DataSourceProperty.DRIVER_CLASS_NAME, Class.class, (dataSource) -> dataSource.getDriver().getClass(),

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/JsonValueWriter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,9 @@ else if (ObjectUtils.isArray(value)) {
103103
else if (value instanceof Map<?, ?> map) {
104104
writeObject(map::forEach);
105105
}
106-
else if (value instanceof Number) {
106+
else if (value instanceof Number || value instanceof Boolean) {
107107
append(value.toString());
108108
}
109-
else if (value instanceof Boolean bool) {
110-
append(bool ? "true" : "false");
111-
}
112109
else {
113110
writeString(value);
114111
}

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

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,43 +51,49 @@ public void initialize(ConfigurableApplicationContext applicationContext) {
5151
applicationContext.addApplicationListener(new Listener(applicationContext));
5252
}
5353

54-
private record Listener(ConfigurableApplicationContext applicationContext) implements ApplicationListener<RSocketServerInitializedEvent> {
54+
private static class Listener implements ApplicationListener<RSocketServerInitializedEvent> {
5555

56-
private static final String PROPERTY_NAME = "local.rsocket.server.port";
56+
private static final String PROPERTY_NAME = "local.rsocket.server.port";
5757

58-
private static final String PROPERTY_SOURCE_NAME = "server.ports";
58+
private static final String PROPERTY_SOURCE_NAME = "server.ports";
59+
60+
private final ConfigurableApplicationContext applicationContext;
61+
62+
Listener(ConfigurableApplicationContext applicationContext) {
63+
this.applicationContext = applicationContext;
64+
}
5965

6066
@Override
61-
public void onApplicationEvent(RSocketServerInitializedEvent event) {
62-
if (event.getServer().address() != null) {
63-
setPortProperty(this.applicationContext, event.getServer().address().getPort());
64-
}
67+
public void onApplicationEvent(RSocketServerInitializedEvent event) {
68+
if (event.getServer().address() != null) {
69+
setPortProperty(this.applicationContext, event.getServer().address().getPort());
6570
}
71+
}
6672

67-
private void setPortProperty(ApplicationContext context, int port) {
68-
if (context instanceof ConfigurableApplicationContext configurableContext) {
69-
setPortProperty(configurableContext.getEnvironment(), port);
70-
}
71-
if (context.getParent() != null) {
72-
setPortProperty(context.getParent(), port);
73-
}
73+
private void setPortProperty(ApplicationContext context, int port) {
74+
if (context instanceof ConfigurableApplicationContext configurableContext) {
75+
setPortProperty(configurableContext.getEnvironment(), port);
7476
}
75-
76-
private void setPortProperty(ConfigurableEnvironment environment, int port) {
77-
MutablePropertySources sources = environment.getPropertySources();
78-
PropertySource<?> source = sources.get(PROPERTY_SOURCE_NAME);
79-
if (source == null) {
80-
source = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>());
81-
sources.addFirst(source);
82-
}
83-
setPortProperty(port, source);
77+
if (context.getParent() != null) {
78+
setPortProperty(context.getParent(), port);
8479
}
80+
}
8581

86-
@SuppressWarnings("unchecked")
87-
private void setPortProperty(int port, PropertySource<?> source) {
88-
((Map<String, Object>) source.getSource()).put(PROPERTY_NAME, port);
82+
private void setPortProperty(ConfigurableEnvironment environment, int port) {
83+
MutablePropertySources sources = environment.getPropertySources();
84+
PropertySource<?> source = sources.get(PROPERTY_SOURCE_NAME);
85+
if (source == null) {
86+
source = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>());
87+
sources.addFirst(source);
8988
}
89+
setPortProperty(port, source);
90+
}
9091

92+
@SuppressWarnings("unchecked")
93+
private void setPortProperty(int port, PropertySource<?> source) {
94+
((Map<String, Object>) source.getSource()).put(PROPERTY_NAME, port);
9195
}
9296

97+
}
98+
9399
}

0 commit comments

Comments
 (0)