Upgrade to Spring Framework 7.0.0-M5

This commit also adapts to the new Jackson 3.0 baseline.

Closes gh-1202
This commit is contained in:
Brian Clozel
2025-05-20 18:59:04 +02:00
parent ce90154953
commit 7d7749a2b2
39 changed files with 462 additions and 161 deletions

View File

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

View File

@@ -8,7 +8,7 @@ javaPlatform {
dependencies {
api(platform("org.springframework:spring-framework-bom:${springFrameworkVersion}"))
api(platform("com.fasterxml.jackson:jackson-bom:2.18.3"))
api(platform("tools.jackson:jackson-bom:3.0.0-rc4"))
api(platform("io.projectreactor:reactor-bom:2025.0.0-M3"))
api(platform("io.micrometer:micrometer-bom:1.15.0"))
api(platform("io.micrometer:micrometer-tracing-bom:1.5.0"))

View File

@@ -452,8 +452,8 @@ You can then create `JsonKeysetCursorStrategy`:
ObjectMapper mapper = ... ;
CodecConfigurer configurer = ServerCodecConfigurer.create();
configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper));
configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper));
configurer.defaultCodecs().jacksonJsonDecoder(new JacksonJsonDecoder(mapper));
configurer.defaultCodecs().jacksonJsonEncoder(new JacksonJsonEncoder(mapper));
JsonKeysetCursorStrategy strategy = new JsonKeysetCursorStrategy(configurer);
----

View File

@@ -14,6 +14,7 @@ dependencies {
compileOnly 'org.springframework:spring-websocket'
compileOnly 'org.springframework:spring-messaging'
compileOnly 'jakarta.servlet:jakarta.servlet-api'
compileOnly 'tools.jackson.core:jackson-databind'
compileOnly 'io.rsocket:rsocket-core'
compileOnly 'io.rsocket:rsocket-transport-netty'
compileOnly 'org.skyscreamer:jsonassert'
@@ -32,7 +33,7 @@ dependencies {
testImplementation 'io.projectreactor.netty:reactor-netty'
testImplementation 'io.rsocket:rsocket-transport-local'
testImplementation 'io.micrometer:context-propagation'
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
testImplementation 'tools.jackson.core:jackson-databind'
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl'

View File

@@ -24,8 +24,6 @@ import java.util.function.Function;
import java.util.function.Predicate;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import org.jspecify.annotations.Nullable;
import reactor.core.publisher.Flux;
@@ -60,8 +58,8 @@ import org.springframework.util.ClassUtils;
*/
public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTesterBuilder<B>> implements GraphQlTester.Builder<B> {
private static final boolean jackson2Present = ClassUtils.isPresent(
"com.fasterxml.jackson.databind.ObjectMapper", AbstractGraphQlClientBuilder.class.getClassLoader());
private static final boolean jacksonPresent = ClassUtils.isPresent(
"tools.jackson.databind.ObjectMapper", AbstractGraphQlClientBuilder.class.getClassLoader());
private static final Duration DEFAULT_RESPONSE_DURATION = Duration.ofSeconds(5);
@@ -130,8 +128,8 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
*/
protected GraphQlTester buildGraphQlTester(GraphQlTransport transport) {
if (jackson2Present) {
configureJsonPathConfig(Jackson2Configurer::configure);
if (jacksonPresent) {
configureJsonPathConfig(JacksonConfigurer::configure);
}
return new DefaultGraphQlTester(transport, this.errorFilter,
@@ -195,7 +193,7 @@ public abstract class AbstractGraphQlTesterBuilder<B extends AbstractGraphQlTest
}
private static final class Jackson2Configurer {
private static final class JacksonConfigurer {
private static final Class<?> defaultJsonProviderType;

View File

@@ -0,0 +1,88 @@
/*
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.graphql.test.tester;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import com.jayway.jsonpath.InvalidJsonException;
import com.jayway.jsonpath.spi.json.AbstractJsonProvider;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;
/**
* {@link com.jayway.jsonpath.spi.json.JsonProvider} for Jackson 3.x.
* @author Brian Clozel
*/
class JacksonJsonProvider extends AbstractJsonProvider {
private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectReader objectReader = this.objectMapper.reader();
@Override
public Object parse(String json) throws InvalidJsonException {
try {
return this.objectReader.readValue(json);
}
catch (JacksonException exc) {
throw new InvalidJsonException(exc, json);
}
}
@Override
public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException {
try {
return this.objectReader.readValue(new InputStreamReader(jsonStream, charset));
}
catch (IOException exc) {
throw new InvalidJsonException(exc);
}
}
@Override
public String toJson(Object obj) {
StringWriter writer = new StringWriter();
try {
JsonGenerator generator = this.objectMapper.createGenerator(writer);
this.objectMapper.writeValue(generator, obj);
writer.flush();
writer.close();
generator.close();
return writer.getBuffer().toString();
}
catch (IOException exc) {
throw new InvalidJsonException(exc);
}
}
@Override
public Object createArray() {
return new LinkedList<Object>();
}
@Override
public Object createMap() {
return new LinkedHashMap<String, Object>();
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.graphql.test.tester;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.TypeRef;
import com.jayway.jsonpath.spi.mapper.MappingException;
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.ObjectMapper;
/**
* {@link MappingProvider} for Jackson 3.x.
* @author Brian Clozel
*/
class JacksonMappingProvider implements MappingProvider {
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public <T> @Nullable T map(@Nullable Object source, Class<T> targetType, Configuration configuration) {
if (source == null) {
return null;
}
try {
return this.objectMapper.convertValue(source, targetType);
}
catch (Exception exc) {
throw new MappingException(exc);
}
}
@Override
@SuppressWarnings("unchecked")
public <T> @Nullable T map(@Nullable Object source, final TypeRef<T> targetType, Configuration configuration) {
if (source == null) {
return null;
}
JavaType type = this.objectMapper.getTypeFactory().constructType(targetType.getType());
try {
return (T) this.objectMapper.convertValue(source, type);
}
catch (Exception exc) {
throw new MappingException(exc);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.util.MimeType;
@@ -91,10 +91,10 @@ class GraphQlTesterBuilderTests extends GraphQlTesterTestSupport {
@Test
void codecConfigurerRegistersJsonPathMappingProvider() {
TestJackson2JsonDecoder testDecoder = new TestJackson2JsonDecoder();
TestJacksonJsonDecoder testDecoder = new TestJacksonJsonDecoder();
ExecutionGraphQlServiceTester.Builder<?> builder = graphQlTesterBuilder()
.encoder(new Jackson2JsonEncoder())
.encoder(new JacksonJsonEncoder())
.decoder(testDecoder);
String document = "{me {name}}";
@@ -138,7 +138,7 @@ class GraphQlTesterBuilderTests extends GraphQlTesterTestSupport {
}
private static class TestJackson2JsonDecoder extends Jackson2JsonDecoder {
private static class TestJacksonJsonDecoder extends JacksonJsonDecoder {
@Nullable
private Object lastValue;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.execution.MockExecutionGraphQlService;
import org.springframework.graphql.server.GraphQlRSocketHandler;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.rsocket.RSocketStrategies;
@@ -87,12 +87,12 @@ class RSocketGraphQlTesterBuilderTests {
@Test
void rsocketStrategiesRegistersJsonPathMappingProvider() {
TestJackson2JsonDecoder testDecoder = new TestJackson2JsonDecoder();
TestJacksonJsonDecoder testDecoder = new TestJacksonJsonDecoder();
RSocketGraphQlTester.Builder<?> builder = this.builderSetup.initBuilder()
.rsocketRequester(requesterBuilder -> {
RSocketStrategies strategies = RSocketStrategies.builder()
.encoder(new Jackson2JsonEncoder())
.encoder(new JacksonJsonEncoder())
.decoder(testDecoder)
.build();
requesterBuilder.rsocketStrategies(strategies);
@@ -132,7 +132,7 @@ class RSocketGraphQlTesterBuilderTests {
public RSocketGraphQlTester.Builder<?> initBuilder() {
GraphQlRSocketController controller = new GraphQlRSocketController(
new GraphQlRSocketHandler(this.graphQlService, Collections.emptyList(), new Jackson2JsonEncoder()));
new GraphQlRSocketHandler(this.graphQlService, Collections.emptyList(), new JacksonJsonEncoder()));
this.server = RSocketServer.create()
.acceptor(createSocketAcceptor(controller))
@@ -146,8 +146,8 @@ class RSocketGraphQlTesterBuilderTests {
private SocketAcceptor createSocketAcceptor(GraphQlRSocketController controller) {
RSocketStrategies.Builder builder = RSocketStrategies.builder();
builder.encoder(new Jackson2JsonEncoder());
builder.decoder(new Jackson2JsonDecoder());
builder.encoder(new JacksonJsonEncoder());
builder.decoder(new JacksonJsonDecoder());
RSocketMessageHandler handler = new RSocketMessageHandler();
handler.setHandlers(Collections.singletonList(controller));
@@ -195,7 +195,7 @@ class RSocketGraphQlTesterBuilderTests {
}
private static class TestJackson2JsonDecoder extends Jackson2JsonDecoder {
private static class TestJacksonJsonDecoder extends JacksonJsonDecoder {
@Nullable
private Object lastValue;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ import org.springframework.graphql.server.webflux.GraphQlHttpHandler;
import org.springframework.graphql.server.webflux.GraphQlWebSocketHandler;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.http.codec.ClientCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.lang.Nullable;
import org.springframework.test.web.reactive.server.WebTestClient;
import org.springframework.util.Assert;
@@ -168,7 +168,7 @@ class WebGraphQlTesterBuilderTests {
@MethodSource("argumentSource")
void codecConfigurerRegistersJsonPathMappingProvider(TesterBuilderSetup builderSetup) {
TestJackson2JsonDecoder testDecoder = new TestJackson2JsonDecoder();
TestJacksonJsonDecoder testDecoder = new TestJacksonJsonDecoder();
WebGraphQlTester.Builder<?> builder = builderSetup.initBuilder()
.codecConfigurer(codecConfigurer -> codecConfigurer.customCodecs().register(testDecoder));
@@ -267,7 +267,7 @@ class WebGraphQlTesterBuilderTests {
}
private static class TestJackson2JsonDecoder extends Jackson2JsonDecoder {
private static class TestJacksonJsonDecoder extends JacksonJsonDecoder {
@Nullable
private Object lastValue;

View File

@@ -32,7 +32,7 @@ dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-reflect"
compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core'
compileOnly 'com.fasterxml.jackson.core:jackson-databind'
compileOnly 'tools.jackson.core:jackson-databind'
compileOnly('com.apollographql.federation:federation-graphql-java-support')
compileOnly('com.netflix.graphql.dgs.codegen:graphql-dgs-codegen-shared-core') {
@@ -81,8 +81,7 @@ dependencies {
testImplementation 'jakarta.persistence:jakarta.persistence-api'
testImplementation 'jakarta.validation:jakarta.validation-api'
testImplementation 'com.jayway.jsonpath:json-path'
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
testImplementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
testImplementation 'tools.jackson.core:jackson-databind'
testImplementation 'org.apache.tomcat.embed:tomcat-embed-el:10.0.21'
testImplementation 'com.apollographql.federation:federation-graphql-java-support'
@@ -93,7 +92,7 @@ dependencies {
testFixturesApi 'org.springframework:spring-webflux'
testFixturesApi 'org.junit.jupiter:junit-jupiter-engine'
testFixturesApi 'com.squareup.okhttp3:mockwebserver'
testFixturesApi 'com.fasterxml.jackson.core:jackson-databind'
testFixturesApi 'tools.jackson.core:jackson-databind'
}
test {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@ import org.springframework.graphql.client.GraphQlClientInterceptor.SubscriptionC
import org.springframework.graphql.support.CachingDocumentSource;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.graphql.support.ResourceDocumentSource;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -55,8 +55,8 @@ import org.springframework.util.ClassUtils;
*/
public abstract class AbstractGraphQlClientBuilder<B extends AbstractGraphQlClientBuilder<B>> implements GraphQlClient.Builder<B> {
protected static final boolean jackson2Present = ClassUtils.isPresent(
"com.fasterxml.jackson.databind.ObjectMapper", AbstractGraphQlClientBuilder.class.getClassLoader());
protected static final boolean jacksonPresent = ClassUtils.isPresent(
"tools.jackson.databind.ObjectMapper", AbstractGraphQlClientBuilder.class.getClassLoader());
private final List<GraphQlClientInterceptor> interceptors = new ArrayList<>();
@@ -177,9 +177,9 @@ public abstract class AbstractGraphQlClientBuilder<B extends AbstractGraphQlClie
*/
protected GraphQlClient buildGraphQlClient(GraphQlTransport transport) {
if (jackson2Present) {
this.jsonEncoder = (this.jsonEncoder == null) ? DefaultJackson2Codecs.encoder() : this.jsonEncoder;
this.jsonDecoder = (this.jsonDecoder == null) ? DefaultJackson2Codecs.decoder() : this.jsonDecoder;
if (jacksonPresent) {
this.jsonEncoder = (this.jsonEncoder == null) ? DefaultJacksonCodecs.encoder() : this.jsonEncoder;
this.jsonDecoder = (this.jsonDecoder == null) ? DefaultJacksonCodecs.decoder() : this.jsonDecoder;
}
return new DefaultGraphQlClient(this.documentSource,
@@ -231,14 +231,14 @@ public abstract class AbstractGraphQlClientBuilder<B extends AbstractGraphQlClie
}
protected static class DefaultJackson2Codecs {
protected static class DefaultJacksonCodecs {
static Encoder<?> encoder() {
return new Jackson2JsonEncoder();
return new JacksonJsonEncoder();
}
static Decoder<?> decoder() {
return new Jackson2JsonDecoder();
return new JacksonJsonDecoder();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.springframework.graphql.support.CachingDocumentSource;
import org.springframework.graphql.support.DocumentSource;
import org.springframework.graphql.support.ResourceDocumentSource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -57,8 +57,8 @@ import org.springframework.util.ClassUtils;
public abstract class AbstractGraphQlClientSyncBuilder<B extends AbstractGraphQlClientSyncBuilder<B>>
implements GraphQlClient.SyncBuilder<B> {
protected static final boolean jackson2Present = ClassUtils.isPresent(
"com.fasterxml.jackson.databind.ObjectMapper", AbstractGraphQlClientSyncBuilder.class.getClassLoader());
protected static final boolean jacksonPresent = ClassUtils.isPresent(
"tools.jackson.databind.ObjectMapper", AbstractGraphQlClientSyncBuilder.class.getClassLoader());
private final List<SyncGraphQlClientInterceptor> interceptors = new ArrayList<>();
@@ -144,7 +144,7 @@ public abstract class AbstractGraphQlClientSyncBuilder<B extends AbstractGraphQl
*/
protected GraphQlClient buildGraphQlClient(SyncGraphQlTransport transport) {
if (jackson2Present) {
if (jacksonPresent) {
this.jsonConverter = (this.jsonConverter == null) ?
DefaultJacksonConverter.initialize() : this.jsonConverter;
}
@@ -189,7 +189,7 @@ public abstract class AbstractGraphQlClientSyncBuilder<B extends AbstractGraphQl
private static final class DefaultJacksonConverter {
static HttpMessageConverter<Object> initialize() {
return new MappingJackson2HttpMessageConverter();
return new JacksonJsonHttpMessageConverter();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -69,11 +69,11 @@ final class DefaultRSocketGraphQlClientBuilder
private static RSocketRequester.Builder initRSocketRequestBuilder() {
RSocketRequester.Builder requesterBuilder = RSocketRequester.builder().dataMimeType(MimeTypeUtils.APPLICATION_JSON);
if (jackson2Present) {
if (jacksonPresent) {
requesterBuilder.rsocketStrategies(
RSocketStrategies.builder()
.encoder(DefaultJackson2Codecs.encoder())
.decoder(DefaultJackson2Codecs.decoder())
.encoder(DefaultJacksonCodecs.encoder())
.decoder(DefaultJacksonCodecs.decoder())
.build());
}
return requesterBuilder;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,9 +22,12 @@ import java.util.Collections;
import java.util.Date;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
import tools.jackson.databind.DefaultTyping;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.cfg.DateTimeFeature;
import tools.jackson.databind.json.JsonMapper;
import tools.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
import tools.jackson.databind.jsontype.PolymorphicTypeValidator;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.Decoder;
@@ -38,9 +41,8 @@ import org.springframework.http.codec.CodecConfigurer;
import org.springframework.http.codec.DecoderHttpMessageReader;
import org.springframework.http.codec.EncoderHttpMessageWriter;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.MimeTypeUtils;
@@ -57,8 +59,8 @@ public final class JsonKeysetCursorStrategy implements CursorStrategy<Map<String
private static final ResolvableType MAP_TYPE =
ResolvableType.forClassWithGenerics(Map.class, String.class, Object.class);
private static final boolean jackson2Present = ClassUtils.isPresent(
"com.fasterxml.jackson.databind.ObjectMapper", JsonKeysetCursorStrategy.class.getClassLoader());
private static final boolean jacksonPresent = ClassUtils.isPresent(
"tools.jackson.databind.ObjectMapper", JsonKeysetCursorStrategy.class.getClassLoader());
private final Encoder<?> encoder;
@@ -77,7 +79,7 @@ public final class JsonKeysetCursorStrategy implements CursorStrategy<Map<String
private static ServerCodecConfigurer initCodecConfigurer() {
ServerCodecConfigurer configurer = ServerCodecConfigurer.create();
if (jackson2Present) {
if (jacksonPresent) {
JacksonObjectMapperCustomizer.customize(configurer);
}
return configurer;
@@ -148,11 +150,13 @@ public final class JsonKeysetCursorStrategy implements CursorStrategy<Map<String
.allowIfSubType(Date.class)
.build();
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().build();
mapper.activateDefaultTyping(validator, ObjectMapper.DefaultTyping.NON_FINAL);
JsonMapper mapper = JsonMapper.builder()
.activateDefaultTyping(validator, DefaultTyping.NON_FINAL)
.enable(DateTimeFeature.WRITE_DATES_AS_TIMESTAMPS)
.build();
configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper));
configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper));
configurer.defaultCodecs().jacksonJsonDecoder(new JacksonJsonDecoder(mapper));
configurer.defaultCodecs().jacksonJsonEncoder(new JacksonJsonEncoder(mapper));
}
}

View File

@@ -60,7 +60,6 @@ import org.springframework.graphql.server.support.GraphQlWebSocketMessage;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.GenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
@@ -102,7 +101,7 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
private final Duration initTimeoutDuration;
private final HttpMessageConverter<?> converter;
private final HttpMessageConverter<Object> converter;
private final @Nullable Duration keepAliveDuration;
@@ -117,7 +116,7 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
* the WebSocket for the {@code "connection_ini"} message from the client.
*/
public GraphQlWebSocketHandler(
WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter, Duration connectionInitTimeout) {
WebGraphQlHandler graphQlHandler, HttpMessageConverter<Object> converter, Duration connectionInitTimeout) {
this(graphQlHandler, converter, connectionInitTimeout, null);
}
@@ -133,7 +132,7 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
* @since 1.3
*/
public GraphQlWebSocketHandler(
WebGraphQlHandler graphQlHandler, HttpMessageConverter<?> converter,
WebGraphQlHandler graphQlHandler, HttpMessageConverter<Object> converter,
Duration connectionInitTimeout, @Nullable Duration keepAliveDuration) {
Assert.notNull(graphQlHandler, "WebGraphQlHandler is required");
@@ -289,10 +288,9 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
}
}
@SuppressWarnings("unchecked")
private GraphQlWebSocketMessage decode(TextMessage message) throws IOException {
return ((GenericHttpMessageConverter<GraphQlWebSocketMessage>) this.converter)
.read(GraphQlWebSocketMessage.class, null, new HttpInputMessageAdapter(message));
return (GraphQlWebSocketMessage) this.converter
.read(GraphQlWebSocketMessage.class, new HttpInputMessageAdapter(message));
}
private SessionState getSessionInfo(WebSocketSession session) {

View File

@@ -0,0 +1,88 @@
/*
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.graphql;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import com.jayway.jsonpath.InvalidJsonException;
import com.jayway.jsonpath.spi.json.AbstractJsonProvider;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonGenerator;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectReader;
/**
* {@link com.jayway.jsonpath.spi.json.JsonProvider} for Jackson 3.x.
* @author Brian Clozel
*/
class JacksonJsonProvider extends AbstractJsonProvider {
private final ObjectMapper objectMapper = new ObjectMapper();
private final ObjectReader objectReader = this.objectMapper.reader();
@Override
public Object parse(String json) throws InvalidJsonException {
try {
return this.objectReader.readValue(json);
}
catch (JacksonException exc) {
throw new InvalidJsonException(exc, json);
}
}
@Override
public Object parse(InputStream jsonStream, String charset) throws InvalidJsonException {
try {
return this.objectReader.readValue(new InputStreamReader(jsonStream, charset));
}
catch (IOException exc) {
throw new InvalidJsonException(exc);
}
}
@Override
public String toJson(Object obj) {
StringWriter writer = new StringWriter();
try {
JsonGenerator generator = this.objectMapper.createGenerator(writer);
this.objectMapper.writeValue(generator, obj);
writer.flush();
writer.close();
generator.close();
return writer.getBuffer().toString();
}
catch (IOException exc) {
throw new InvalidJsonException(exc);
}
}
@Override
public Object createArray() {
return new LinkedList<Object>();
}
@Override
public Object createMap() {
return new LinkedHashMap<String, Object>();
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.graphql;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.TypeRef;
import com.jayway.jsonpath.spi.mapper.MappingException;
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import org.jspecify.annotations.Nullable;
import tools.jackson.databind.JavaType;
import tools.jackson.databind.ObjectMapper;
/**
* {@link MappingProvider} for Jackson 3.x.
* @author Brian Clozel
*/
class JacksonMappingProvider implements MappingProvider {
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public <T> @Nullable T map(@Nullable Object source, Class<T> targetType, Configuration configuration) {
if (source == null) {
return null;
}
try {
return this.objectMapper.convertValue(source, targetType);
}
catch (Exception exc) {
throw new MappingException(exc);
}
}
@Override
@SuppressWarnings("unchecked")
public <T> @Nullable T map(@Nullable Object source, final TypeRef<T> targetType, Configuration configuration) {
if (source == null) {
return null;
}
JavaType type = this.objectMapper.getTypeFactory().constructType(targetType.getType());
try {
return (T) this.objectMapper.convertValue(source, type);
}
catch (Exception exc) {
throw new MappingException(exc);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,8 +25,6 @@ import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.TypeRef;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
import graphql.ExecutionResult;
import graphql.GraphQLError;
import graphql.execution.ResultPath;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@
package org.springframework.graphql;
import io.micrometer.context.ThreadLocalAccessor;
import org.jspecify.annotations.Nullable;
import org.springframework.lang.Nullable;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,14 +26,15 @@ import graphql.GraphQLError;
import graphql.GraphqlErrorBuilder;
import graphql.execution.ResultPath;
import graphql.language.SourceLocation;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.DeserializationFeature;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.graphql.ResponseError;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -184,7 +185,7 @@ class DefaultGraphQlClientResponseTests {
return new DefaultClientGraphQlResponse(
new DefaultClientGraphQlRequest("{test}", null, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap()),
new ResponseMapGraphQlResponse(responseMap),
new Jackson2JsonEncoder(), new Jackson2JsonDecoder());
new JacksonJsonEncoder(), new JacksonJsonDecoder());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,11 +17,11 @@
package org.springframework.graphql.client;
import java.io.IOException;
import java.lang.reflect.Type;
import java.net.URI;
import java.util.Collections;
import graphql.ExecutionResultImpl;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
@@ -41,9 +41,8 @@ import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.reactive.ClientHttpConnector;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.lang.Nullable;
import org.springframework.mock.http.client.MockClientHttpRequest;
import org.springframework.mock.http.client.MockClientHttpResponse;
import org.springframework.test.web.reactive.server.HttpHandlerConnector;
@@ -193,7 +192,7 @@ class HttpSyncGraphQlClientBuilderTests {
@Test
void codecConfigurerRegistersJsonPathMappingProvider() {
TestJackson2JsonConverter testConverter = new TestJackson2JsonConverter();
TestJacksonJsonConverter testConverter = new TestJacksonJsonConverter();
HttpSyncGraphQlClient.Builder<?> builder = this.setup.initBuilder();
builder.messageConverters(converters -> converters.add(0, testConverter));
@@ -295,7 +294,7 @@ class HttpSyncGraphQlClientBuilderTests {
}
private static class TestJackson2JsonConverter extends MappingJackson2HttpMessageConverter {
private static class TestJacksonJsonConverter extends JacksonJsonHttpMessageConverter {
@Nullable
private Object lastValue;
@@ -306,10 +305,8 @@ class HttpSyncGraphQlClientBuilderTests {
}
@Override
public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
this.lastValue = super.read(type, contextClass, inputMessage);
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
this.lastValue = super.readInternal(clazz, inputMessage);
return this.lastValue;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.function.Function;
import graphql.GraphQLError;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -33,7 +34,6 @@ import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.server.support.GraphQlWebSocketMessage;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.http.codec.ClientCodecConfigurer;
import org.springframework.lang.Nullable;
import org.springframework.web.reactive.socket.WebSocketHandler;
import org.springframework.web.reactive.socket.WebSocketSession;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,8 @@
package org.springframework.graphql.client;
import org.springframework.lang.Nullable;
import org.jspecify.annotations.Nullable;
import org.springframework.util.ObjectUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import io.rsocket.SocketAcceptor;
import io.rsocket.core.RSocketServer;
import io.rsocket.transport.local.LocalClientTransport;
import io.rsocket.transport.local.LocalServerTransport;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
@@ -33,9 +34,8 @@ import reactor.core.publisher.Mono;
import org.springframework.graphql.GraphQlRequest;
import org.springframework.graphql.execution.MockExecutionGraphQlService;
import org.springframework.graphql.server.GraphQlRSocketHandler;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.rsocket.RSocketStrategies;
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
@@ -108,7 +108,7 @@ class RSocketGraphQlClientBuilderTests {
public RSocketGraphQlClient.Builder<?> initBuilder() {
GraphQlRSocketController controller = new GraphQlRSocketController(
new GraphQlRSocketHandler(this.graphQlService, Collections.emptyList(), new Jackson2JsonEncoder()));
new GraphQlRSocketHandler(this.graphQlService, Collections.emptyList(), new JacksonJsonEncoder()));
this.server = RSocketServer.create()
.acceptor(createSocketAcceptor(controller))
@@ -122,8 +122,8 @@ class RSocketGraphQlClientBuilderTests {
private SocketAcceptor createSocketAcceptor(GraphQlRSocketController controller) {
RSocketStrategies.Builder builder = RSocketStrategies.builder();
builder.encoder(new Jackson2JsonEncoder());
builder.decoder(new Jackson2JsonDecoder());
builder.encoder(new JacksonJsonEncoder());
builder.decoder(new JacksonJsonDecoder());
RSocketMessageHandler handler = new RSocketMessageHandler();
handler.setHandlers(Collections.singletonList(controller));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import io.rsocket.core.RSocketServer;
import io.rsocket.exceptions.RejectedException;
import io.rsocket.transport.local.LocalClientTransport;
import io.rsocket.transport.local.LocalServerTransport;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
@@ -33,9 +34,8 @@ import reactor.test.StepVerifier;
import org.springframework.graphql.GraphQlResponse;
import org.springframework.graphql.ResponseError;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.lang.Nullable;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.RSocketStrategies;
@@ -49,9 +49,9 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class RSocketGraphQlTransportTests {
private static final Jackson2JsonEncoder jsonEncoder = new Jackson2JsonEncoder();
private static final JacksonJsonEncoder jsonEncoder = new JacksonJsonEncoder();
private static final Jackson2JsonDecoder jsonDecoder = new Jackson2JsonDecoder();
private static final JacksonJsonDecoder jsonDecoder = new JacksonJsonDecoder();
@Nullable

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Stream;
import graphql.ExecutionResultImpl;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -42,9 +43,8 @@ import org.springframework.graphql.support.DocumentSource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.codec.ClientCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.server.reactive.HttpHandler;
import org.springframework.lang.Nullable;
import org.springframework.test.web.reactive.server.HttpHandlerConnector;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
@@ -212,7 +212,7 @@ class WebGraphQlClientBuilderTests {
@MethodSource("argumentSource")
void codecConfigurerRegistersJsonPathMappingProvider(ClientBuilderSetup setup) {
TestJackson2JsonDecoder testDecoder = new TestJackson2JsonDecoder();
TestJacksonJsonDecoder testDecoder = new TestJacksonJsonDecoder();
WebGraphQlClient.Builder<?> builder = setup.initBuilder();
builder.codecConfigurer(codecConfigurer -> codecConfigurer.customCodecs().register(testDecoder));
@@ -335,7 +335,7 @@ class WebGraphQlClientBuilderTests {
}
private static class TestJackson2JsonDecoder extends Jackson2JsonDecoder {
private static class TestJacksonJsonDecoder extends JacksonJsonDecoder {
@Nullable
private Object lastValue;

View File

@@ -29,10 +29,10 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.DataFetchingEnvironmentImpl;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.ObjectMapper;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,11 @@ package org.springframework.graphql.data.method.annotation.support;
import java.lang.reflect.Method;
import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.DataFetchingEnvironmentImpl;
import tools.jackson.core.JacksonException;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.ObjectMapper;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.MethodParameter;
@@ -52,7 +52,7 @@ class ArgumentResolverTestSupport {
return methodParam;
}
protected DataFetchingEnvironment environment(String argumentsJson) throws JsonProcessingException {
protected DataFetchingEnvironment environment(String argumentsJson) throws JacksonException {
Map<String, Object> arguments = this.mapper.readValue(argumentsJson, MAP_TYPE_REFERENCE);
return DataFetchingEnvironmentImpl.newDataFetchingEnvironment().arguments(arguments).build();
}

View File

@@ -65,7 +65,7 @@ class SortMethodArgumentResolverTests extends ArgumentResolverTestSupport {
private void testResolver(Function<DataFetchingEnvironment, Sort> resolveFunction) throws Exception {
DataFetchingEnvironment environment = environment("""
{ "sortFields": ["firstName", "lastName", "id"], "sortDirection": "DESC"}"
{ "sortFields": ["firstName", "lastName", "id"], "sortDirection": "DESC" }
""");
Sort sort = resolveFunction.apply(environment);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2024 the original author or authors.
* Copyright 2020-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
import com.mongodb.reactivestreams.client.MongoClients;
import graphql.schema.DataFetcher;
import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.junit.jupiter.Container;
@@ -54,7 +55,6 @@ import org.springframework.graphql.server.WebGraphQlRequest;
import org.springframework.graphql.server.WebGraphQlResponse;
import org.springframework.graphql.support.DefaultGraphQlRequest;
import org.springframework.http.HttpHeaders;
import org.springframework.lang.Nullable;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ import org.springframework.core.codec.Encoder;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.server.webflux.GraphQlWebSocketHandler;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,7 +48,7 @@ class GraphQlRSocketHandlerTests {
private static final Duration TIMEOUT = Duration.ofSeconds(5);
private final Encoder<?> encoder = new Jackson2JsonEncoder();
private final Encoder<?> encoder = new JacksonJsonEncoder();
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,12 +21,12 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import tools.jackson.databind.ObjectMapper;
import org.springframework.core.codec.DataBufferEncoder;
import org.springframework.core.io.buffer.DefaultDataBuffer;
@@ -42,8 +42,8 @@ import org.springframework.http.codec.EncoderHttpMessageWriter;
import org.springframework.http.codec.HttpMessageReader;
import org.springframework.http.codec.HttpMessageWriter;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
import org.springframework.mock.web.server.MockServerWebExchange;
@@ -60,7 +60,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class GraphQlHttpHandlerTests {
private static final List<HttpMessageReader<?>> MESSAGE_READERS =
List.of(new DecoderHttpMessageReader<>(new Jackson2JsonDecoder()));
List.of(new DecoderHttpMessageReader<>(new JacksonJsonDecoder()));
private final GraphQlHttpHandler greetingHandler =
GraphQlSetup.schemaContent("type Query { greeting: String }")
@@ -184,8 +184,8 @@ class GraphQlHttpHandlerTests {
ObjectMapper mapper = new ObjectMapper();
CodecConfigurer configurer = ServerCodecConfigurer.create();
configurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(mapper));
configurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(mapper));
configurer.defaultCodecs().jacksonJsonDecoder(new JacksonJsonDecoder(mapper));
configurer.defaultCodecs().jacksonJsonEncoder(new JacksonJsonEncoder(mapper));
byte[] bytes = "{\"query\": \"{showId}\"}".getBytes(StandardCharsets.UTF_8);
Flux<DefaultDataBuffer> body = Flux.just(DefaultDataBufferFactory.sharedInstance.wrap(bytes));
@@ -230,7 +230,7 @@ class GraphQlHttpHandlerTests {
@Override
public List<HttpMessageWriter<?>> messageWriters() {
return Collections.singletonList(new EncoderHttpMessageWriter<>(new Jackson2JsonEncoder()));
return Collections.singletonList(new EncoderHttpMessageWriter<>(new JacksonJsonEncoder()));
}
@Override

View File

@@ -34,7 +34,7 @@ import org.springframework.graphql.server.support.SerializableGraphQlRequest;
import org.springframework.http.MediaType;
import org.springframework.http.codec.HttpMessageWriter;
import org.springframework.http.codec.ServerSentEventHttpMessageWriter;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.http.codec.json.JacksonJsonEncoder;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
import org.springframework.mock.http.server.reactive.MockServerHttpResponse;
import org.springframework.mock.web.reactive.function.server.MockServerRequest;
@@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class GraphQlSseHandlerTests {
private static final List<HttpMessageWriter<?>> MESSAGE_WRITERS =
List.of(new ServerSentEventHttpMessageWriter(new Jackson2JsonEncoder()));
List.of(new ServerSentEventHttpMessageWriter(new JacksonJsonEncoder()));
private static final DataFetcher<?> SEARCH_DATA_FETCHER = env -> {
String author = env.getArgument("author");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ import org.springframework.graphql.server.WebSocketSessionInfo;
import org.springframework.graphql.server.support.GraphQlWebSocketMessage;
import org.springframework.graphql.server.support.GraphQlWebSocketMessageType;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.JacksonJsonDecoder;
import org.springframework.web.reactive.socket.CloseStatus;
import org.springframework.web.reactive.socket.WebSocketMessage;
@@ -67,7 +67,7 @@ import static org.springframework.graphql.server.support.GraphQlWebSocketMessage
*/
class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
private static final Jackson2JsonDecoder decoder = new Jackson2JsonDecoder();
private static final JacksonJsonDecoder decoder = new JacksonJsonDecoder();
private static final Duration TIMEOUT = Duration.ofSeconds(5);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import graphql.execution.preparsed.persisted.ApolloPersistedQuerySupport;
import graphql.execution.preparsed.persisted.InMemoryPersistedQueryCache;
import jakarta.servlet.ServletException;
import org.junit.jupiter.api.Test;
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.graphql.GraphQlSetup;
@@ -40,7 +40,7 @@ import org.springframework.graphql.server.support.SerializableGraphQlRequest;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.web.servlet.function.AsyncServerResponse;
@@ -58,7 +58,7 @@ import static org.assertj.core.api.Assertions.assertThatNoException;
class GraphQlHttpHandlerTests {
private static final List<HttpMessageConverter<?>> MESSAGE_READERS =
List.of(new MappingJackson2HttpMessageConverter(), new ByteArrayHttpMessageConverter());
List.of(new JacksonJsonHttpMessageConverter(), new ByteArrayHttpMessageConverter());
private final GraphQlHttpHandler greetingHandler = GraphQlSetup.schemaContent("type Query { greeting: String }")
.queryFetcher("greeting", (env) -> "Hello").toHttpHandler();
@@ -145,7 +145,7 @@ class GraphQlHttpHandlerTests {
WebGraphQlHandler webGraphQlHandler = GraphQlSetup.schemaContent("type Query { greeting: String }")
.queryFetcher("greeting", (env) -> "Hello").toWebGraphQlHandler();
GraphQlHttpHandler handler = new GraphQlHttpHandler(webGraphQlHandler, new MappingJackson2HttpMessageConverter());
GraphQlHttpHandler handler = new GraphQlHttpHandler(webGraphQlHandler, new JacksonJsonHttpMessageConverter());
MockHttpServletRequest servletRequest = createServletRequest("{ greeting }", MediaTypes.APPLICATION_GRAPHQL_RESPONSE.toString());
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());

View File

@@ -39,7 +39,7 @@ import org.springframework.graphql.GraphQlSetup;
import org.springframework.graphql.server.WebGraphQlHandler;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.mock.web.MockAsyncContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
@@ -63,7 +63,7 @@ import static org.mockito.Mockito.mock;
class GraphQlSseHandlerTests {
private static final List<HttpMessageConverter<?>> MESSAGE_READERS =
List.of(new MappingJackson2HttpMessageConverter());
List.of(new JacksonJsonHttpMessageConverter());
private static final AtomicBoolean DATA_FETCHER_CANCELLED = new AtomicBoolean();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,9 +55,8 @@ import org.springframework.graphql.server.support.GraphQlWebSocketMessage;
import org.springframework.graphql.server.support.GraphQlWebSocketMessageType;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.GenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketMessage;
@@ -73,7 +72,7 @@ import static org.springframework.graphql.server.support.GraphQlWebSocketMessage
*/
class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
private static final HttpMessageConverter<?> converter = new MappingJackson2HttpMessageConverter();
private static final HttpMessageConverter<Object> converter = new JacksonJsonHttpMessageConverter();
private static final Duration TIMEOUT = Duration.ofSeconds(5);
@@ -494,8 +493,7 @@ class GraphQlWebSocketHandlerTests extends WebSocketHandlerTestSupport {
private GraphQlWebSocketMessage decode(WebSocketMessage<?> message) {
try {
HttpInputMessageAdapter inputMessage = new HttpInputMessageAdapter((TextMessage) message);
return ((GenericHttpMessageConverter<GraphQlWebSocketMessage>) converter)
.read(GraphQlWebSocketMessage.class, null, inputMessage);
return (GraphQlWebSocketMessage) converter.read(GraphQlWebSocketMessage.class, inputMessage);
}
catch (IOException ex) {
throw new IllegalStateException(ex);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,8 +23,6 @@ import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Stream;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import graphql.ExecutionInput;
import graphql.ExecutionResult;
import graphql.ExecutionResultImpl;
@@ -32,6 +30,8 @@ import graphql.GraphQLError;
import graphql.GraphqlErrorBuilder;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import tools.jackson.core.JacksonException;
import tools.jackson.databind.ObjectMapper;
import org.springframework.graphql.ExecutionGraphQlRequest;
import org.springframework.graphql.ExecutionGraphQlResponse;
@@ -175,7 +175,7 @@ public class MockExecutionGraphQlService implements ExecutionGraphQlService {
try {
return OBJECT_MAPPER.readValue(json, Map.class);
}
catch (JsonProcessingException ex) {
catch (JacksonException ex) {
throw new IllegalStateException(ex);
}
}