Skip to content

Commit cb6cd3e

Browse files
author
Andreas Höhmann
committed
wip: move on to springboot 4.0.0-M3 and springcloud 2025.1.0-M2
- cleaned also all "invalid" code-formattings from previous commits - one big problem in spring-boot-admin-server jackson's databind module 3.0.0-rc9 was included into spring which conflicts here and there with the old jackson stuff?!
1 parent b4d6f50 commit cb6cd3e

File tree

23 files changed

+275
-253
lines changed

23 files changed

+275
-253
lines changed

spring-boot-admin-client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,10 @@
118118
<artifactId>awaitility</artifactId>
119119
<scope>test</scope>
120120
</dependency>
121+
<dependency>
122+
<groupId>com.fasterxml.jackson.core</groupId>
123+
<artifactId>jackson-databind</artifactId>
124+
<scope>test</scope>
125+
</dependency>
121126
</dependencies>
122127
</project>

spring-boot-admin-client/src/main/java/de/codecentric/boot/admin/client/registration/DefaultApplicationFactory.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public class DefaultApplicationFactory implements ApplicationFactory {
6363
@Nullable
6464
private Integer localManagementPort;
6565

66-
public DefaultApplicationFactory(final InstanceProperties instance, final ManagementServerProperties management,
67-
final ServerProperties server, final PathMappedEndpoints pathMappedEndpoints,
68-
final WebEndpointProperties webEndpoint, final MetadataContributor metadataContributor) {
66+
public DefaultApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
67+
ServerProperties server, PathMappedEndpoints pathMappedEndpoints, WebEndpointProperties webEndpoint,
68+
MetadataContributor metadataContributor) {
6969
this.instance = instance;
7070
this.management = management;
7171
this.server = server;
@@ -97,7 +97,7 @@ protected String getServiceUrl() {
9797
}
9898

9999
protected String getServiceBaseUrl() {
100-
final String baseUrl = this.instance.getServiceBaseUrl();
100+
String baseUrl = this.instance.getServiceBaseUrl();
101101

102102
if (StringUtils.hasText(baseUrl)) {
103103
return baseUrl;
@@ -111,7 +111,7 @@ protected String getServiceBaseUrl() {
111111
}
112112

113113
protected String getServicePath() {
114-
final String path = this.instance.getServicePath();
114+
String path = this.instance.getServicePath();
115115

116116
if (StringUtils.hasText(path)) {
117117
return path;
@@ -132,7 +132,7 @@ protected String getManagementUrl() {
132132
}
133133

134134
protected String getManagementBaseUrl() {
135-
final String baseUrl = this.instance.getManagementBaseUrl();
135+
String baseUrl = this.instance.getManagementBaseUrl();
136136

137137
if (StringUtils.hasText(baseUrl)) {
138138
return baseUrl;
@@ -142,7 +142,7 @@ protected String getManagementBaseUrl() {
142142
return this.getServiceUrl();
143143
}
144144

145-
final Ssl ssl = (this.management.getSsl() != null) ? this.management.getSsl() : this.server.getSsl();
145+
Ssl ssl = (this.management.getSsl() != null) ? this.management.getSsl() : this.server.getSsl();
146146
return UriComponentsBuilder.newInstance()
147147
.scheme(getScheme(ssl))
148148
.host(getManagementHost())
@@ -169,7 +169,7 @@ protected String getHealthUrl() {
169169
}
170170

171171
protected Map<String, String> getMetadata() {
172-
final Map<String, String> metadata = new LinkedHashMap<>();
172+
Map<String, String> metadata = new LinkedHashMap<>();
173173
metadata.putAll(this.metadataContributor.getMetadata());
174174
metadata.putAll(this.instance.getMetadata());
175175
return metadata;
@@ -184,7 +184,7 @@ protected String getServiceHost() {
184184
}
185185

186186
protected String getManagementHost() {
187-
final InetAddress address = this.management.getAddress();
187+
InetAddress address = this.management.getAddress();
188188
if (address != null) {
189189
return getHost(address);
190190
}
@@ -195,7 +195,7 @@ protected InetAddress getLocalHost() {
195195
try {
196196
return InetAddress.getLocalHost();
197197
}
198-
catch (final UnknownHostException ex) {
198+
catch (UnknownHostException ex) {
199199
throw new IllegalArgumentException(ex.getMessage(), ex);
200200
}
201201
}
@@ -216,22 +216,22 @@ protected Integer getLocalManagementPort() {
216216
}
217217

218218
protected String getHealthEndpointPath() {
219-
final String health = this.pathMappedEndpoints.getPath(EndpointId.of("health"));
219+
String health = this.pathMappedEndpoints.getPath(EndpointId.of("health"));
220220
if (StringUtils.hasText(health)) {
221221
return health;
222222
}
223-
final String status = this.pathMappedEndpoints.getPath(EndpointId.of("status"));
223+
String status = this.pathMappedEndpoints.getPath(EndpointId.of("status"));
224224
if (StringUtils.hasText(status)) {
225225
return status;
226226
}
227227
throw new IllegalStateException("Either health or status endpoint must be enabled!");
228228
}
229229

230-
protected String getScheme(@Nullable final Ssl ssl) {
230+
protected String getScheme(@Nullable Ssl ssl) {
231231
return ((ssl != null) && ssl.isEnabled()) ? "https" : "http";
232232
}
233233

234-
protected String getHost(final InetAddress address) {
234+
protected String getHost(InetAddress address) {
235235
if (this.instance.isPreferIp()) {
236236
return address.getHostAddress();
237237
}
@@ -244,8 +244,8 @@ protected String getHost(final InetAddress address) {
244244
}
245245

246246
@EventListener
247-
public void onWebServerInitialized(final WebServerInitializedEvent event) {
248-
final String name = event.getApplicationContext().getServerNamespace();
247+
public void onWebServerInitialized(WebServerInitializedEvent event) {
248+
String name = event.getApplicationContext().getServerNamespace();
249249
if ("server".equals(name) || !StringUtils.hasText(name)) {
250250
this.localServerPort = event.getWebServer().getPort();
251251
}

spring-boot-admin-client/src/main/java/de/codecentric/boot/admin/client/registration/ServletApplicationFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public class ServletApplicationFactory extends DefaultApplicationFactory {
4141

4242
private final DispatcherServletPath dispatcherServletPath;
4343

44-
public ServletApplicationFactory(final InstanceProperties instance, final ManagementServerProperties management,
45-
final ServerProperties server, final ServletContext servletContext,
46-
final PathMappedEndpoints pathMappedEndpoints, final WebEndpointProperties webEndpoint,
47-
final MetadataContributor metadataContributor, final DispatcherServletPath dispatcherServletPath) {
44+
public ServletApplicationFactory(InstanceProperties instance, ManagementServerProperties management,
45+
ServerProperties server, ServletContext servletContext, PathMappedEndpoints pathMappedEndpoints,
46+
WebEndpointProperties webEndpoint, MetadataContributor metadataContributor,
47+
DispatcherServletPath dispatcherServletPath) {
4848
super(instance, management, server, pathMappedEndpoints, webEndpoint, metadataContributor);
4949
this.servletContext = servletContext;
5050
this.server = server;
@@ -67,7 +67,7 @@ protected String getServiceUrl() {
6767

6868
@Override
6969
protected String getManagementBaseUrl() {
70-
final String baseUrl = this.instance.getManagementBaseUrl();
70+
String baseUrl = this.instance.getManagementBaseUrl();
7171

7272
if (StringUtils.hasText(baseUrl)) {
7373
return baseUrl;
@@ -81,7 +81,7 @@ protected String getManagementBaseUrl() {
8181
.toUriString();
8282
}
8383

84-
final Ssl ssl = (this.management.getSsl() != null) ? this.management.getSsl() : this.server.getSsl();
84+
Ssl ssl = (this.management.getSsl() != null) ? this.management.getSsl() : this.server.getSsl();
8585
return UriComponentsBuilder.newInstance()
8686
.scheme(getScheme(ssl))
8787
.host(getManagementHost())

spring-boot-admin-client/src/test/java/de/codecentric/boot/admin/client/config/SpringBootAdminClientAutoConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public static class CustomBlockingConfiguration {
185185

186186
@Bean
187187
public RegistrationClient registrationClient() {
188-
return registrationClient;
188+
return this.registrationClient;
189189
}
190190

191191
}

spring-boot-admin-client/src/test/java/de/codecentric/boot/admin/client/registration/CloudFoundryApplicationFactoryTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ void should_use_application_uri() {
6161
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
6262
this.cfApplicationProperties.setUris(singletonList("application/Uppercase"));
6363

64-
final Application app = this.factory.createApplication();
64+
Application app = this.factory.createApplication();
6565

66-
final SoftAssertions softly = new SoftAssertions();
66+
SoftAssertions softly = new SoftAssertions();
6767
softly.assertThat(app.getManagementUrl()).isEqualTo("http://application/Uppercase/actuator");
6868
softly.assertThat(app.getHealthUrl()).isEqualTo("http://application/Uppercase/actuator/health");
6969
softly.assertThat(app.getServiceUrl()).isEqualTo("http://application/Uppercase/");
@@ -76,9 +76,9 @@ void should_use_service_base_uri() {
7676
this.cfApplicationProperties.setUris(singletonList("application/Uppercase"));
7777
this.instanceProperties.setServiceBaseUrl("https://serviceBaseUrl");
7878

79-
final Application app = this.factory.createApplication();
79+
Application app = this.factory.createApplication();
8080

81-
final SoftAssertions softly = new SoftAssertions();
81+
SoftAssertions softly = new SoftAssertions();
8282
softly.assertThat(app.getManagementUrl()).isEqualTo("https://serviceBaseUrl/actuator");
8383
softly.assertThat(app.getHealthUrl()).isEqualTo("https://serviceBaseUrl/actuator/health");
8484
softly.assertThat(app.getServiceUrl()).isEqualTo("https://serviceBaseUrl/");

spring-boot-admin-client/src/test/java/de/codecentric/boot/admin/client/registration/ReactiveApplicationFactoryTest.java

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,71 +52,72 @@ class ReactiveApplicationFactoryTest {
5252

5353
private final WebFluxProperties webflux = new WebFluxProperties();
5454

55-
private final ReactiveApplicationFactory factory = new ReactiveApplicationFactory(instanceProperties, management,
56-
server, pathMappedEndpoints, webEndpoint, () -> singletonMap("contributor", "test"), webflux);
55+
private final ReactiveApplicationFactory factory = new ReactiveApplicationFactory(this.instanceProperties,
56+
this.management, this.server, this.pathMappedEndpoints, this.webEndpoint,
57+
() -> singletonMap("contributor", "test"), this.webflux);
5758

5859
@BeforeEach
5960
void setup() {
60-
instanceProperties.setName("test");
61+
this.instanceProperties.setName("test");
6162
}
6263

6364
@Test
6465
void test_contextPath_mgmtPath() {
65-
webflux.setBasePath("/app");
66-
webEndpoint.setBasePath("/admin");
67-
when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health");
68-
publishApplicationReadyEvent(factory, 8080, null);
66+
this.webflux.setBasePath("/app");
67+
this.webEndpoint.setBasePath("/admin");
68+
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health");
69+
publishApplicationReadyEvent(this.factory, 8080, null);
6970

70-
final Application app = factory.createApplication();
71+
Application app = this.factory.createApplication();
7172
assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8080/app/admin");
7273
assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8080/app/admin/health");
7374
assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/app");
7475
}
7576

7677
@Test
7778
void test_contextPath_mgmtPortPath() {
78-
webflux.setBasePath("/app");
79-
webEndpoint.setBasePath("/admin");
80-
when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health");
81-
publishApplicationReadyEvent(factory, 8080, 8081);
79+
this.webflux.setBasePath("/app");
80+
this.webEndpoint.setBasePath("/admin");
81+
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/admin/health");
82+
publishApplicationReadyEvent(this.factory, 8080, 8081);
8283

83-
final Application app = factory.createApplication();
84+
Application app = this.factory.createApplication();
8485
assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8081/admin");
8586
assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8081/admin/health");
8687
assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/app");
8788
}
8889

8990
@Test
9091
void test_basePath() {
91-
webflux.setBasePath("/app");
92-
when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
93-
publishApplicationReadyEvent(factory, 80, null);
92+
this.webflux.setBasePath("/app");
93+
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
94+
publishApplicationReadyEvent(this.factory, 80, null);
9495

95-
final Application app = factory.createApplication();
96+
Application app = this.factory.createApplication();
9697
assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":80/app/actuator");
9798
assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":80/app/actuator/health");
9899
assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":80/app");
99100
}
100101

101102
@Test
102103
void test_noBasePath() {
103-
when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
104-
publishApplicationReadyEvent(factory, 80, null);
104+
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
105+
publishApplicationReadyEvent(this.factory, 80, null);
105106

106-
final Application app = factory.createApplication();
107+
Application app = this.factory.createApplication();
107108
assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":80/actuator");
108109
assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":80/actuator/health");
109110
assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":80/");
110111
}
111112

112113
@Test
113114
void test_mgmtBasePath_mgmtPortPath() {
114-
webflux.setBasePath("/app");
115-
management.setBasePath("/mgnt");
116-
when(pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
117-
publishApplicationReadyEvent(factory, 8080, 8081);
115+
this.webflux.setBasePath("/app");
116+
this.management.setBasePath("/mgnt");
117+
when(this.pathMappedEndpoints.getPath(EndpointId.of("health"))).thenReturn("/actuator/health");
118+
publishApplicationReadyEvent(this.factory, 8080, 8081);
118119

119-
final Application app = factory.createApplication();
120+
Application app = this.factory.createApplication();
120121
assertThat(app.getManagementUrl()).isEqualTo("http://" + getHostname() + ":8081/mgnt/actuator");
121122
assertThat(app.getHealthUrl()).isEqualTo("http://" + getHostname() + ":8081/mgnt/actuator/health");
122123
assertThat(app.getServiceUrl()).isEqualTo("http://" + getHostname() + ":8080/app");
@@ -126,13 +127,13 @@ private String getHostname() {
126127
try {
127128
return InetAddress.getLocalHost().getCanonicalHostName();
128129
}
129-
catch (final UnknownHostException ex) {
130+
catch (UnknownHostException ex) {
130131
throw new IllegalStateException(ex);
131132
}
132133
}
133134

134-
private void publishApplicationReadyEvent(final DefaultApplicationFactory factory, final Integer serverport,
135-
final Integer managementport) {
135+
private void publishApplicationReadyEvent(DefaultApplicationFactory factory, Integer serverport,
136+
Integer managementport) {
136137
factory.onWebServerInitialized(new TestWebServerInitializedEvent("server", serverport));
137138
factory.onWebServerInitialized(new TestWebServerInitializedEvent("management",
138139
(managementport != null) ? managementport : serverport));
@@ -144,15 +145,15 @@ private static final class TestWebServerInitializedEvent extends WebServerInitia
144145

145146
private final WebServerApplicationContext context = mock(WebServerApplicationContext.class);
146147

147-
private TestWebServerInitializedEvent(final String name, final int port) {
148+
private TestWebServerInitializedEvent(String name, int port) {
148149
super(mock(WebServer.class));
149-
when(server.getPort()).thenReturn(port);
150-
when(context.getServerNamespace()).thenReturn(name);
150+
when(this.server.getPort()).thenReturn(port);
151+
when(this.context.getServerNamespace()).thenReturn(name);
151152
}
152153

153154
@Override
154155
public WebServerApplicationContext getApplicationContext() {
155-
return context;
156+
return this.context;
156157
}
157158

158159
@Override

0 commit comments

Comments
 (0)