Upgrade to Spring Framework 7.0.0-M4

This commit requires Spring Framework 7.0 to run applications.
This also means we follow Framework 7.0's baseline with Jakarta 11.

See gh-1202
This commit is contained in:
Brian Clozel
2025-05-21 09:28:14 +02:00
parent cac5909528
commit bc8b0277c6
7 changed files with 34 additions and 33 deletions

View File

@@ -2,7 +2,7 @@ description = "Spring for GraphQL"
ext {
moduleProjects = [project(":spring-graphql"), project(":spring-graphql-test")]
springFrameworkVersion = "6.2.7"
springFrameworkVersion = "7.0.0-M4"
graphQlJavaVersion = "24.0"
springBootVersion = "3.4.3"
}

View File

@@ -28,10 +28,10 @@ dependencies {
api("com.graphql-java:graphql-java:${graphQlJavaVersion}")
api("io.micrometer:context-propagation:1.1.3")
api("jakarta.annotation:jakarta.annotation-api:2.1.1")
api("jakarta.servlet:jakarta.servlet-api:6.0.0")
api("jakarta.validation:jakarta.validation-api:3.0.2")
api("jakarta.persistence:jakarta.persistence-api:3.1.0")
api("jakarta.annotation:jakarta.annotation-api:3.0.0")
api("jakarta.servlet:jakarta.servlet-api:6.1.0")
api("jakarta.validation:jakarta.validation-api:3.1.0")
api("jakarta.persistence:jakarta.persistence-api:3.2.0")
api("com.apollographql.federation:federation-graphql-java-support:5.4.0")
api("com.netflix.graphql.dgs.codegen:graphql-dgs-codegen-shared-core:8.0.4")
@@ -43,8 +43,8 @@ dependencies {
api("com.squareup.okhttp3:mockwebserver:4.12.0")
api("com.h2database:h2:2.3.232")
api("org.hibernate:hibernate-core:6.6.11.Final")
api("org.hibernate.validator:hibernate-validator:8.0.2.Final")
api("org.hibernate.orm:hibernate-core:7.0.0.CR1")
api("org.hibernate.validator:hibernate-validator:9.0.0.CR1")
api("org.mongodb:bson:5.3.1")
api("org.mongodb:mongodb-driver-core:5.3.1")
api("org.mongodb:mongodb-driver-reactivestreams:5.3.1")

View File

@@ -62,7 +62,7 @@ dependencies {
}
testImplementation 'io.micrometer:micrometer-tracing-test'
testImplementation 'com.h2database:h2'
testImplementation 'org.hibernate:hibernate-core'
testImplementation 'org.hibernate.orm:hibernate-core'
testImplementation 'org.hibernate.validator:hibernate-validator'
testImplementation 'org.springframework.data:spring-data-mongodb'
testImplementation 'org.springframework.data:spring-data-neo4j'

View File

@@ -571,14 +571,13 @@ class SchemaMappingBeanFactoryInitializationAotProcessorTests {
}
private void assertThatIntrospectionOnMethodsHintRegisteredForType(Class<?> type) {
Predicate<RuntimeHints> predicate = RuntimeHintsPredicates.reflection()
.onType(type).withAnyMemberCategory(MemberCategory.INTROSPECT_DECLARED_METHODS);
Predicate<RuntimeHints> predicate = RuntimeHintsPredicates.reflection().onType(type);
assertThat(predicate).accepts(this.generationContext.getRuntimeHints());
}
private void assertThatInvocationHintRegisteredForMethods(Class<?> type, String... methodNames) {
Predicate<RuntimeHints> predicate = Arrays.stream(methodNames)
.map(methodName -> (Predicate<RuntimeHints>) RuntimeHintsPredicates.reflection().onMethod(type, methodName))
.map(methodName -> RuntimeHintsPredicates.reflection().onMethodInvocation(type, methodName))
.reduce(Predicate::and)
.orElseThrow(() -> new IllegalArgumentException("Could not generate predicate on type " + type + " for methods " + Arrays.toString(methodNames)));
assertThat(predicate).accepts(this.generationContext.getRuntimeHints());
@@ -602,18 +601,18 @@ class SchemaMappingBeanFactoryInitializationAotProcessorTests {
private Predicate<RuntimeHints> javaBeanBindingOnType(Class<?> type) {
Predicate<RuntimeHints> predicate = RuntimeHintsPredicates.reflection().onType(type)
.withMemberCategories(MemberCategory.DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
.withMemberCategories(MemberCategory.ACCESS_DECLARED_FIELDS, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
try {
BeanInfo beanInfo = Introspector.getBeanInfo(type);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
Method readMethod = propertyDescriptor.getReadMethod();
if (readMethod != null && readMethod.getDeclaringClass() != Object.class) {
predicate = predicate.and(RuntimeHintsPredicates.reflection().onMethod(readMethod));
predicate = predicate.and(RuntimeHintsPredicates.reflection().onMethodInvocation(readMethod));
}
Method writeMethod = propertyDescriptor.getWriteMethod();
if (writeMethod != null && writeMethod.getDeclaringClass() != Object.class) {
predicate = predicate.and(RuntimeHintsPredicates.reflection().onMethod(writeMethod));
predicate = predicate.and(RuntimeHintsPredicates.reflection().onMethodInvocation(writeMethod));
}
}
}

View File

@@ -386,15 +386,15 @@ class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
new ReflectiveRuntimeHintsRegistrar().registerRuntimeHints(runtimeHints, GraphQlWebSocketHandler.class);
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
assertThat(reflection.onType(GraphQlWebSocketMessage.class)).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "id")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getId")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setId")).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "type")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getType")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setType")).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "payload")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getPayload")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setPayload")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "id")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getId")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setId")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "type")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getType")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setType")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "payload")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getPayload")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setPayload")).accepts(runtimeHints);
}
private TestWebSocketSession handle(Flux<WebSocketMessage> input, WebGraphQlInterceptor... interceptors) {

View File

@@ -18,6 +18,7 @@ package org.springframework.graphql.server.webmvc;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
@@ -190,7 +191,8 @@ class GraphQlSseHandlerTests {
HttpServletResponse servletResponse = mock(HttpServletResponse.class);
ServletOutputStream outputStream = mock(ServletOutputStream.class);
willThrow(new IOException("broken pipe")).given(outputStream).write(any());
willThrow(new IOException("broken pipe")).given(outputStream).write(any(byte[].class));
willThrow(new IOException("broken pipe")).given(outputStream).write(any(ByteBuffer.class));
given(servletResponse.getOutputStream()).willReturn(outputStream);
ServerRequest request = ServerRequest.create(servletRequest, MESSAGE_READERS);

View File

@@ -456,15 +456,15 @@ class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
new ReflectiveRuntimeHintsRegistrar().registerRuntimeHints(runtimeHints, GraphQlWebSocketHandler.class);
ReflectionHintsPredicates reflection = RuntimeHintsPredicates.reflection();
assertThat(reflection.onType(GraphQlWebSocketMessage.class)).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "id")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getId")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setId")).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "type")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getType")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setType")).accepts(runtimeHints);
assertThat(reflection.onField(GraphQlWebSocketMessage.class, "payload")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "getPayload")).accepts(runtimeHints);
assertThat(reflection.onMethod(GraphQlWebSocketMessage.class, "setPayload")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "id")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getId")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setId")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "type")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getType")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setType")).accepts(runtimeHints);
assertThat(reflection.onFieldAccess(GraphQlWebSocketMessage.class, "payload")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "getPayload")).accepts(runtimeHints);
assertThat(reflection.onMethodInvocation(GraphQlWebSocketMessage.class, "setPayload")).accepts(runtimeHints);
}
private void handle(GraphQlWebSocketHandler handler, TextMessage... textMessages) throws Exception {