From 285dcda3f565591cb53ffe44e73a8d7fefba81f2 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 12 Mar 2025 21:13:14 +0100 Subject: [PATCH] Remove deprecated code Closes gh-1151 --- .../graphql/data/GraphQlArgumentBinder.java | 17 +-------- .../AnnotatedControllerConfigurer.java | 15 +------- .../DefaultExecutionGraphQlService.java | 37 +------------------ .../ExecutionRequestObservationContext.java | 21 +---------- .../webmvc/GraphQlWebSocketHandler.java | 14 +------ .../client/TestWebSocketConnection.java | 5 ++- 6 files changed, 8 insertions(+), 101 deletions(-) diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java b/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java index 3d889a8c..984874e0 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java @@ -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 consumer) { - } - - /** * Create and populate an Object of the given target type, from a single * GraphQL argument, or from the full GraphQL arguments map. diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java index a26ce862..ea06482a 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerConfigurer.java @@ -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 consumer) { - } - @Override public void afterPropertiesSet() { diff --git a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java index 94f9f2d0..a5ed6153 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/execution/DefaultExecutionGraphQlService.java @@ -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 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); - } - } - } - } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationContext.java b/spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationContext.java index 919b90bf..b07956dd 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationContext.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/observation/ExecutionRequestObservationContext.java @@ -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; - } - } diff --git a/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java b/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java index efa95012..f4109c1e 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandler.java @@ -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) { diff --git a/spring-graphql/src/testFixtures/java/org/springframework/graphql/client/TestWebSocketConnection.java b/spring-graphql/src/testFixtures/java/org/springframework/graphql/client/TestWebSocketConnection.java index d8abd4c3..b683dcad 100644 --- a/spring-graphql/src/testFixtures/java/org/springframework/graphql/client/TestWebSocketConnection.java +++ b/spring-graphql/src/testFixtures/java/org/springframework/graphql/client/TestWebSocketConnection.java @@ -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