From bb44c0e13a2b0cb3e808f5b184ea7c7a1bcd63b1 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Thu, 21 Apr 2022 21:04:17 +0000 Subject: [PATCH] Polishing See gh-28386 --- .../springframework/web/service/annotation/GetRequest.java | 1 + .../web/service/annotation/PostRequest.java | 1 + .../springframework/web/service/annotation/PutRequest.java | 1 + .../web/service/invoker/HttpRequestDefinition.java | 5 ++--- .../web/service/invoker/HttpServiceProxyFactory.java | 7 ++----- .../springframework/web/service/invoker/package-info.java | 3 ++- .../service/invoker/HttpMethodArgumentResolverTests.java | 4 ++-- .../service/invoker/PathVariableArgumentResolverTests.java | 2 -- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java index 58cba909645..3160bd364cb 100644 --- a/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java +++ b/spring-web/src/main/java/org/springframework/web/service/annotation/GetRequest.java @@ -26,6 +26,7 @@ import org.springframework.core.annotation.AliasFor; /** + * Shortcut for {@link HttpRequest} for HTTP GET requests. * * @author Rossen Stoyanchev * @since 6.0 diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java index 5fb3d950a03..7a824a4df4f 100644 --- a/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java +++ b/spring-web/src/main/java/org/springframework/web/service/annotation/PostRequest.java @@ -25,6 +25,7 @@ import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; /** + * Shortcut for {@link HttpRequest} for HTTP POST requests. * * @author Rossen Stoyanchev * @since 6.0 diff --git a/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java b/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java index 91c173d7988..f553497f6de 100644 --- a/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java +++ b/spring-web/src/main/java/org/springframework/web/service/annotation/PutRequest.java @@ -25,6 +25,7 @@ import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; /** + * Shortcut for {@link HttpRequest} for HTTP PUT requests. * * @author Rossen Stoyanchev * @since 6.0 diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java index 846815a7db8..ee6a266a2ad 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpRequestDefinition.java @@ -28,7 +28,6 @@ import org.reactivestreams.Publisher; import org.springframework.core.MethodParameter; import org.springframework.core.ParameterizedTypeReference; -import org.springframework.core.ResolvableType; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpRequest; @@ -56,7 +55,7 @@ public class HttpRequestDefinition { @Nullable private URI uri; - + @Nullable private String uriTemplate; @@ -80,7 +79,7 @@ public class HttpRequestDefinition { @Nullable private Publisher bodyPublisher; - + @Nullable private ParameterizedTypeReference bodyPublisherElementType; diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java index 686d8745146..2817db212fa 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceProxyFactory.java @@ -24,8 +24,6 @@ import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.springframework.aop.framework.ProxyFactory; import org.springframework.core.MethodIntrospector; @@ -91,7 +89,7 @@ public class HttpServiceProxyFactory { /** - * + * {@link MethodInterceptor} that invokes an {@link HttpServiceMethod}. */ private static final class HttpServiceMethodInterceptor implements MethodInterceptor { @@ -101,9 +99,8 @@ public class HttpServiceProxyFactory { methods.forEach(serviceMethod -> this.serviceMethodMap.put(serviceMethod.getMethod(), serviceMethod)); } - @Nullable @Override - public Object invoke(@NotNull MethodInvocation invocation) throws Throwable { + public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); HttpServiceMethod httpServiceMethod = this.serviceMethodMap.get(method); return httpServiceMethod.invoke(invocation.getArguments()); diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java b/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java index e55a4598627..9c5adc46e8c 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/package-info.java @@ -1,5 +1,6 @@ /** - * + * Support to create a client proxy for an HTTP service annotated with + * {@link org.springframework.web.service.annotation.HttpRequest} methods. */ @NonNullApi @NonNullFields diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java index 2ff88877409..b2f5a4f79ba 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/HttpMethodArgumentResolverTests.java @@ -37,13 +37,13 @@ public class HttpMethodArgumentResolverTests { private final Service service = this.clientAdapter.createService(Service.class, new HttpMethodArgumentResolver()); - + @Test void shouldResolveRequestMethodFromArgument() { this.service.execute(HttpMethod.GET); assertThat(getActualMethod()).isEqualTo(HttpMethod.GET); } - + @Test void shouldIgnoreArgumentsNotMatchingType() { this.service.execute("test"); diff --git a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java index 68040657e18..0d7e041e2ef 100644 --- a/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/service/invoker/PathVariableArgumentResolverTests.java @@ -19,7 +19,6 @@ package org.springframework.web.service.invoker; import java.util.Map; import java.util.Optional; -import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; import org.springframework.core.convert.support.DefaultConversionService; @@ -143,7 +142,6 @@ class PathVariableArgumentResolverTests { assertThat(getActualUriVariables().get(name)).isEqualTo(expectedValue); } - @NotNull private Map getActualUriVariables() { return this.clientAdapter.getRequestDefinition().getUriVariables(); }