Skip to content

Commit 285dcda

Browse files
committed
Remove deprecated code
Closes gh-1151
1 parent 0d4fe15 commit 285dcda

File tree

6 files changed

+8
-101
lines changed

6 files changed

+8
-101
lines changed

spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
2222
import java.util.Collections;
2323
import java.util.Map;
2424
import java.util.Optional;
25-
import java.util.function.Consumer;
2625

2726
import graphql.schema.DataFetchingEnvironment;
2827

@@ -46,7 +45,6 @@
4645
import org.springframework.util.ReflectionUtils;
4746
import org.springframework.validation.AbstractBindingResult;
4847
import org.springframework.validation.BindException;
49-
import org.springframework.validation.DataBinder;
5048
import org.springframework.validation.FieldError;
5149

5250

@@ -110,19 +108,6 @@ private static SimpleTypeConverter initTypeConverter(@Nullable ConversionService
110108

111109

112110

113-
/**
114-
* Add a {@link DataBinder} consumer that initializes the binder instance
115-
* before the binding process.
116-
* @param consumer the data binder initializer
117-
* @since 1.0.1
118-
* @deprecated this property is deprecated, ignored, and should not be
119-
* necessary as a {@link DataBinder} is no longer used to bind arguments
120-
*/
121-
@Deprecated(since = "1.1.0", forRemoval = true)
122-
public void addDataBinderInitializer(Consumer<DataBinder> consumer) {
123-
}
124-
125-
126111
/**
127112
* Create and populate an Object of the given target type, from a single
128113
* GraphQL argument, or from the full GraphQL arguments map.

spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@
3030
import java.util.concurrent.CompletableFuture;
3131
import java.util.concurrent.Executor;
3232
import java.util.function.BiConsumer;
33-
import java.util.function.Consumer;
3433
import java.util.function.Predicate;
3534
import java.util.stream.Collectors;
3635

@@ -84,7 +83,6 @@
8483
import org.springframework.util.LinkedMultiValueMap;
8584
import org.springframework.util.MultiValueMap;
8685
import org.springframework.util.StringUtils;
87-
import org.springframework.validation.DataBinder;
8886

8987

9088
/**
@@ -151,17 +149,6 @@ public void setTypeDefinitionRegistry(TypeDefinitionRegistry registry) {
151149
this.interfaceMappingHelper.setTypeDefinitionRegistry(registry);
152150
}
153151

154-
/**
155-
* Configure an initializer that configures the {@link DataBinder} before the binding process.
156-
* @param consumer the data binder initializer
157-
* @since 1.0.1
158-
* @deprecated this property is deprecated, ignored, and should not be
159-
* necessary as a {@link DataBinder} is no longer used to bind arguments
160-
*/
161-
@Deprecated(since = "1.1.0", forRemoval = true)
162-
public void setDataBinderInitializer(@Nullable Consumer<DataBinder> consumer) {
163-
}
164-
165152

166153
@Override
167154
public void afterPropertiesSet() {

spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java

+1-36
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.graphql.execution;
1818

19-
import java.lang.reflect.Field;
2019
import java.util.ArrayList;
2120
import java.util.List;
2221
import java.util.function.BiFunction;
@@ -38,8 +37,6 @@
3837
import org.springframework.graphql.ExecutionGraphQlService;
3938
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
4039
import org.springframework.lang.Nullable;
41-
import org.springframework.util.ClassUtils;
42-
import org.springframework.util.ReflectionUtils;
4340

4441
/**
4542
* {@link ExecutionGraphQlService} that uses a {@link GraphQlSource} to obtain a
@@ -50,9 +47,6 @@
5047
*/
5148
public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
5249

53-
private static final boolean belowGraphQlJava22 = ClassUtils.isPresent(
54-
DataLoaderRegistry21Initializer.CLASS_NAME, ExecutionGraphQlService.class.getClassLoader());
55-
5650
private static final BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput> RESET_EXECUTION_ID_CONFIGURER =
5751
(executionInput, builder) -> builder.executionId(null).build();
5852

@@ -66,15 +60,11 @@ public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
6660

6761
private final boolean isDefaultExecutionIdProvider;
6862

69-
private final Object emptyDataLoaderRegistryInstance;
70-
7163

7264
public DefaultExecutionGraphQlService(GraphQlSource graphQlSource) {
7365
this.graphQlSource = graphQlSource;
7466
this.isDefaultExecutionIdProvider =
7567
(graphQlSource.graphQl().getIdProvider() == ExecutionIdProvider.DEFAULT_EXECUTION_ID_PROVIDER);
76-
this.emptyDataLoaderRegistryInstance = (belowGraphQlJava22) ?
77-
DataLoaderRegistry21Initializer.getInstance() : DataLoaderRegistry22Initializer.getInstance();
7868
}
7969

8070

@@ -121,7 +111,7 @@ private ExecutionInput registerDataLoaders(ExecutionInput executionInput) {
121111
if (this.hasDataLoaderRegistrations) {
122112
GraphQLContext graphQLContext = executionInput.getGraphQLContext();
123113
DataLoaderRegistry existingRegistry = executionInput.getDataLoaderRegistry();
124-
if (existingRegistry == this.emptyDataLoaderRegistryInstance) {
114+
if (existingRegistry == EmptyDataLoaderRegistryInstance.EMPTY_DATALOADER_REGISTRY) {
125115
DataLoaderRegistry newRegistry = DataLoaderRegistry.newRegistry().build();
126116
applyDataLoaderRegistrars(newRegistry, graphQLContext);
127117
executionInput = executionInput.transform((builder) -> builder.dataLoaderRegistry(newRegistry));
@@ -147,29 +137,4 @@ private void applyDataLoaderRegistrars(DataLoaderRegistry registry, GraphQLConte
147137
}
148138

149139

150-
private static final class DataLoaderRegistry22Initializer {
151-
152-
public static Object getInstance() {
153-
return EmptyDataLoaderRegistryInstance.EMPTY_DATALOADER_REGISTRY;
154-
}
155-
}
156-
157-
158-
private static final class DataLoaderRegistry21Initializer {
159-
160-
public static final String CLASS_NAME =
161-
"graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationState";
162-
163-
@SuppressWarnings("DataFlowIssue")
164-
public static Object getInstance() {
165-
try {
166-
Field field = ReflectionUtils.findField(Class.forName(CLASS_NAME), "EMPTY_DATALOADER_REGISTRY");
167-
return ReflectionUtils.getField(field, null);
168-
}
169-
catch (ClassNotFoundException ex) {
170-
throw new RuntimeException(ex);
171-
}
172-
}
173-
}
174-
175140
}

spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationContext.java

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,15 +48,6 @@ public ExecutionInput getExecutionInput() {
4848
return this.executionInput;
4949
}
5050

51-
/**
52-
* Return the {@link ExecutionInput input} for the request execution.
53-
* @deprecated since 1.1.4 in favor of {@link #getExecutionInput()}
54-
*/
55-
@Deprecated(since = "1.1.4", forRemoval = true)
56-
public ExecutionInput getCarrier() {
57-
return this.executionInput;
58-
}
59-
6051
/**
6152
* Return the {@link ExecutionResult result} for the request execution.
6253
* @since 1.1.4
@@ -75,14 +66,4 @@ public void setExecutionResult(ExecutionResult executionResult) {
7566
this.executionResult = executionResult;
7667
}
7768

78-
/**
79-
* Return the {@link ExecutionResult result} for the request execution.
80-
* @deprecated since 1.1.4 in favor of {@link #getExecutionResult()}
81-
*/
82-
@Nullable
83-
@Deprecated(since = "1.1.4", forRemoval = true)
84-
public ExecutionResult getResponse() {
85-
return this.executionResult;
86-
}
87-
8869
}

spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -166,18 +166,6 @@ public WebSocketHttpRequestHandler initWebSocketHttpRequestHandler(HandshakeHand
166166
return handler;
167167
}
168168

169-
/**
170-
* Return a {@link WebSocketHttpRequestHandler} that uses this instance as
171-
* its {@link WebGraphQlHandler} and adds a {@link HandshakeInterceptor} to
172-
* propagate context.
173-
* @param handshakeHandler the handler for WebSocket handshake
174-
* @deprecated as of 1.1.0 in favor of {@link #initWebSocketHttpRequestHandler(HandshakeHandler)}
175-
*/
176-
@Deprecated(since = "1.1.0", forRemoval = true)
177-
public WebSocketHttpRequestHandler asWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) {
178-
return initWebSocketHttpRequestHandler(handshakeHandler);
179-
}
180-
181169

182170
@Override
183171
public void afterConnectionEstablished(WebSocketSession session) {

spring-graphql/src/testFixtures/java/org/springframework/graphql/client/TestWebSocketConnection.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ public Mono<Void> send(Publisher<WebSocketMessage> messages) {
236236
}
237237

238238
private void saveMessage(WebSocketMessage message) {
239-
DataBuffer payload = message.getPayload().retainedSlice(0, message.getPayload().readableByteCount());
240-
this.sentMessages.add(new WebSocketMessage(message.getType(), payload));
239+
DataBuffer payload = message.getPayload();
240+
DataBuffer saved = payload.factory().allocateBuffer(payload.readableByteCount());
241+
this.sentMessages.add(new WebSocketMessage(message.getType(), saved.write(payload)));
241242
}
242243

243244
@Override

0 commit comments

Comments
 (0)