Remove deprecated code

Closes gh-1151
This commit is contained in:
Brian Clozel
2025-03-12 21:13:14 +01:00
parent 0d4fe150aa
commit 285dcda3f5
6 changed files with 8 additions and 101 deletions

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.
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import graphql.schema.DataFetchingEnvironment;
@@ -46,7 +45,6 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.validation.AbstractBindingResult;
import org.springframework.validation.BindException;
import org.springframework.validation.DataBinder;
import org.springframework.validation.FieldError;
@@ -110,19 +108,6 @@ public class GraphQlArgumentBinder {
/**
* Add a {@link DataBinder} consumer that initializes the binder instance
* before the binding process.
* @param consumer the data binder initializer
* @since 1.0.1
* @deprecated this property is deprecated, ignored, and should not be
* necessary as a {@link DataBinder} is no longer used to bind arguments
*/
@Deprecated(since = "1.1.0", forRemoval = true)
public void addDataBinderInitializer(Consumer<DataBinder> consumer) {
}
/**
* Create and populate an Object of the given target type, from a single
* GraphQL argument, or from the full GraphQL arguments map.

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,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@@ -84,7 +83,6 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.validation.DataBinder;
/**
@@ -151,17 +149,6 @@ public class AnnotatedControllerConfigurer
this.interfaceMappingHelper.setTypeDefinitionRegistry(registry);
}
/**
* Configure an initializer that configures the {@link DataBinder} before the binding process.
* @param consumer the data binder initializer
* @since 1.0.1
* @deprecated this property is deprecated, ignored, and should not be
* necessary as a {@link DataBinder} is no longer used to bind arguments
*/
@Deprecated(since = "1.1.0", forRemoval = true)
public void setDataBinderInitializer(@Nullable Consumer<DataBinder> consumer) {
}
@Override
public void afterPropertiesSet() {

View File

@@ -16,7 +16,6 @@
package org.springframework.graphql.execution;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
@@ -38,8 +37,6 @@ import org.springframework.graphql.ExecutionGraphQlResponse;
import org.springframework.graphql.ExecutionGraphQlService;
import org.springframework.graphql.support.DefaultExecutionGraphQlResponse;
import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
* {@link ExecutionGraphQlService} that uses a {@link GraphQlSource} to obtain a
@@ -50,9 +47,6 @@ import org.springframework.util.ReflectionUtils;
*/
public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
private static final boolean belowGraphQlJava22 = ClassUtils.isPresent(
DataLoaderRegistry21Initializer.CLASS_NAME, ExecutionGraphQlService.class.getClassLoader());
private static final BiFunction<ExecutionInput, ExecutionInput.Builder, ExecutionInput> RESET_EXECUTION_ID_CONFIGURER =
(executionInput, builder) -> builder.executionId(null).build();
@@ -66,15 +60,11 @@ public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
private final boolean isDefaultExecutionIdProvider;
private final Object emptyDataLoaderRegistryInstance;
public DefaultExecutionGraphQlService(GraphQlSource graphQlSource) {
this.graphQlSource = graphQlSource;
this.isDefaultExecutionIdProvider =
(graphQlSource.graphQl().getIdProvider() == ExecutionIdProvider.DEFAULT_EXECUTION_ID_PROVIDER);
this.emptyDataLoaderRegistryInstance = (belowGraphQlJava22) ?
DataLoaderRegistry21Initializer.getInstance() : DataLoaderRegistry22Initializer.getInstance();
}
@@ -121,7 +111,7 @@ public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
if (this.hasDataLoaderRegistrations) {
GraphQLContext graphQLContext = executionInput.getGraphQLContext();
DataLoaderRegistry existingRegistry = executionInput.getDataLoaderRegistry();
if (existingRegistry == this.emptyDataLoaderRegistryInstance) {
if (existingRegistry == EmptyDataLoaderRegistryInstance.EMPTY_DATALOADER_REGISTRY) {
DataLoaderRegistry newRegistry = DataLoaderRegistry.newRegistry().build();
applyDataLoaderRegistrars(newRegistry, graphQLContext);
executionInput = executionInput.transform((builder) -> builder.dataLoaderRegistry(newRegistry));
@@ -147,29 +137,4 @@ public class DefaultExecutionGraphQlService implements ExecutionGraphQlService {
}
private static final class DataLoaderRegistry22Initializer {
public static Object getInstance() {
return EmptyDataLoaderRegistryInstance.EMPTY_DATALOADER_REGISTRY;
}
}
private static final class DataLoaderRegistry21Initializer {
public static final String CLASS_NAME =
"graphql.execution.instrumentation.dataloader.DataLoaderDispatcherInstrumentationState";
@SuppressWarnings("DataFlowIssue")
public static Object getInstance() {
try {
Field field = ReflectionUtils.findField(Class.forName(CLASS_NAME), "EMPTY_DATALOADER_REGISTRY");
return ReflectionUtils.getField(field, null);
}
catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
}
}
}

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.
@@ -48,15 +48,6 @@ public class ExecutionRequestObservationContext extends Observation.Context {
return this.executionInput;
}
/**
* Return the {@link ExecutionInput input} for the request execution.
* @deprecated since 1.1.4 in favor of {@link #getExecutionInput()}
*/
@Deprecated(since = "1.1.4", forRemoval = true)
public ExecutionInput getCarrier() {
return this.executionInput;
}
/**
* Return the {@link ExecutionResult result} for the request execution.
* @since 1.1.4
@@ -75,14 +66,4 @@ public class ExecutionRequestObservationContext extends Observation.Context {
this.executionResult = executionResult;
}
/**
* Return the {@link ExecutionResult result} for the request execution.
* @deprecated since 1.1.4 in favor of {@link #getExecutionResult()}
*/
@Nullable
@Deprecated(since = "1.1.4", forRemoval = true)
public ExecutionResult getResponse() {
return this.executionResult;
}
}

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.
@@ -166,18 +166,6 @@ public class GraphQlWebSocketHandler extends TextWebSocketHandler implements Sub
return handler;
}
/**
* Return a {@link WebSocketHttpRequestHandler} that uses this instance as
* its {@link WebGraphQlHandler} and adds a {@link HandshakeInterceptor} to
* propagate context.
* @param handshakeHandler the handler for WebSocket handshake
* @deprecated as of 1.1.0 in favor of {@link #initWebSocketHttpRequestHandler(HandshakeHandler)}
*/
@Deprecated(since = "1.1.0", forRemoval = true)
public WebSocketHttpRequestHandler asWebSocketHttpRequestHandler(HandshakeHandler handshakeHandler) {
return initWebSocketHttpRequestHandler(handshakeHandler);
}
@Override
public void afterConnectionEstablished(WebSocketSession session) {

View File

@@ -236,8 +236,9 @@ public final class TestWebSocketConnection {
}
private void saveMessage(WebSocketMessage message) {
DataBuffer payload = message.getPayload().retainedSlice(0, message.getPayload().readableByteCount());
this.sentMessages.add(new WebSocketMessage(message.getType(), payload));
DataBuffer payload = message.getPayload();
DataBuffer saved = payload.factory().allocateBuffer(payload.readableByteCount());
this.sentMessages.add(new WebSocketMessage(message.getType(), saved.write(payload)));
}
@Override