mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-26 20:09:02 +00:00
Merge branch '4.0.x' into 4.1.x
Closes gh-51865
This commit is contained in:
@@ -61,3 +61,7 @@ dependencies {
|
||||
|
||||
testRuntimeOnly("ch.qos.logback:logback-classic")
|
||||
}
|
||||
|
||||
tasks.named("compileTestJava") {
|
||||
options.nullability.checking = "tests"
|
||||
}
|
||||
|
||||
+5
-4
@@ -26,6 +26,7 @@ import jakarta.ws.rs.ApplicationPath;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -89,9 +90,9 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
|
||||
|
||||
private String subject;
|
||||
|
||||
private String body;
|
||||
private @Nullable String body;
|
||||
|
||||
Message(String subject, String body) {
|
||||
Message(String subject, @Nullable String body) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
}
|
||||
@@ -104,11 +105,11 @@ class JerseyAutoConfigurationCustomObjectMapperProviderTests {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
public @Nullable String getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
public void setBody(@Nullable String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -27,6 +27,7 @@ import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.xml.bind.annotation.XmlTransient;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -89,31 +90,31 @@ class JerseyAutoConfigurationObjectMapperProviderTests {
|
||||
|
||||
public static class Message {
|
||||
|
||||
private String subject;
|
||||
private @Nullable String subject;
|
||||
|
||||
private String body;
|
||||
private @Nullable String body;
|
||||
|
||||
Message() {
|
||||
}
|
||||
|
||||
Message(String subject, String body) {
|
||||
Message(@Nullable String subject, @Nullable String body) {
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
public @Nullable String getSubject() {
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
public void setSubject(@Nullable String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
public @Nullable String getBody() {
|
||||
return this.body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
public void setBody(@Nullable String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -35,6 +35,7 @@ import org.springframework.boot.jersey.autoconfigure.JerseyAutoConfiguration;
|
||||
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -139,9 +140,10 @@ class JerseyEndpointAccessIntegrationTests {
|
||||
}
|
||||
|
||||
private WebTestClient createClient(AssertableWebApplicationContext context) {
|
||||
int port = context.getSourceApplicationContext(ServletWebServerApplicationContext.class)
|
||||
.getWebServer()
|
||||
.getPort();
|
||||
WebServer webServer = context.getSourceApplicationContext(ServletWebServerApplicationContext.class)
|
||||
.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
int port = webServer.getPort();
|
||||
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder()
|
||||
.codecs((configurer) -> configurer.defaultCodecs().maxInMemorySize(-1))
|
||||
.build();
|
||||
|
||||
+16
-9
@@ -40,6 +40,7 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.jersey.autoconfigure.JerseyAutoConfiguration;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -65,9 +66,11 @@ class JerseyEndpointIntegrationTests {
|
||||
getContextRunner(new Class<?>[] { EndpointsConfiguration.class, ResourceConfigConfiguration.class })
|
||||
.withPropertyValues("management.endpoints.web.discovery.enabled:false")
|
||||
.run((context) -> {
|
||||
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer()
|
||||
.getPort();
|
||||
WebServer webServer = context
|
||||
.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
int port = webServer.getPort();
|
||||
WebTestClient client = WebTestClient.bindToServer()
|
||||
.baseUrl("http://localhost:" + port)
|
||||
.responseTimeout(Duration.ofMinutes(5))
|
||||
@@ -86,9 +89,11 @@ class JerseyEndpointIntegrationTests {
|
||||
WebApplicationContextRunner contextRunner = getContextRunner(new Class<?>[] { EndpointsConfiguration.class,
|
||||
ResourceConfigConfiguration.class, EndpointObjectMapperConfiguration.class });
|
||||
contextRunner.run((context) -> {
|
||||
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer()
|
||||
.getPort();
|
||||
WebServer webServer = context
|
||||
.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
int port = webServer.getPort();
|
||||
WebTestClient client = WebTestClient.bindToServer()
|
||||
.baseUrl("http://localhost:" + port)
|
||||
.responseTimeout(Duration.ofMinutes(5))
|
||||
@@ -102,9 +107,11 @@ class JerseyEndpointIntegrationTests {
|
||||
|
||||
protected void testJerseyEndpoints(Class<?>[] userConfigurations) {
|
||||
getContextRunner(userConfigurations).run((context) -> {
|
||||
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer()
|
||||
.getPort();
|
||||
WebServer webServer = context
|
||||
.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
int port = webServer.getPort();
|
||||
WebTestClient client = WebTestClient.bindToServer()
|
||||
.baseUrl("http://localhost:" + port)
|
||||
.responseTimeout(Duration.ofMinutes(5))
|
||||
|
||||
+6
-3
@@ -44,6 +44,7 @@ import org.springframework.boot.test.context.assertj.AssertableWebApplicationCon
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
|
||||
import org.springframework.boot.web.server.WebServer;
|
||||
import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -109,9 +110,11 @@ class JerseyServerMetricsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private static void doRequest(AssertableWebApplicationContext context) {
|
||||
int port = context.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer()
|
||||
.getPort();
|
||||
WebServer webServer = context
|
||||
.getSourceApplicationContext(AnnotationConfigServletWebServerApplicationContext.class)
|
||||
.getWebServer();
|
||||
assertThat(webServer).isNotNull();
|
||||
int port = webServer.getPort();
|
||||
RestClient restClient = RestClient.create();
|
||||
restClient.get().uri(URI.create("http://localhost:" + port + "/users/3")).retrieve().toEntity(String.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user