From 29955a2898264e5ced29b304b1e93fe2cd9eaf70 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 12 Apr 2021 22:41:00 +0200 Subject: [PATCH] Polishing --- .../mvc/method/annotation/RequestBodyAdvice.java | 8 ++++---- .../method/annotation/RequestBodyAdviceAdapter.java | 11 +++++------ .../ResourceHttpRequestHandlerIntegrationTests.java | 4 +++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdvice.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdvice.java index c8c7bc4c742..a50872583b8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdvice.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 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. @@ -57,7 +57,7 @@ public interface RequestBodyAdvice { * @param targetType the target type, not necessarily the same as the method * parameter type, e.g. for {@code HttpEntity}. * @param converterType the converter used to deserialize the body - * @return the input request or a new instance, never {@code null} + * @return the input request or a new instance (never {@code null}) */ HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class> converterType) throws IOException; @@ -83,8 +83,8 @@ public interface RequestBodyAdvice { * @param targetType the target type, not necessarily the same as the method * parameter type, e.g. for {@code HttpEntity}. * @param converterType the selected converter type - * @return the value to use or {@code null} which may then raise an - * {@code HttpMessageNotReadableException} if the argument is required. + * @return the value to use, or {@code null} which may then raise an + * {@code HttpMessageNotReadableException} if the argument is required */ @Nullable Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, MethodParameter parameter, diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdviceAdapter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdviceAdapter.java index c20bd41f7f0..cdb68a7975a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdviceAdapter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestBodyAdviceAdapter.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.mvc.method.annotation; import java.io.IOException; @@ -28,7 +29,7 @@ import org.springframework.lang.Nullable; * {@link org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice * RequestBodyAdvice} with default method implementations. * - *

Sub-classes are required to implement {@link #supports} to return true + *

Subclasses are required to implement {@link #supports} to return true * depending on when the advice applies. * * @author Rossen Stoyanchev @@ -41,8 +42,7 @@ public abstract class RequestBodyAdviceAdapter implements RequestBodyAdvice { */ @Override public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, - Type targetType, Class> converterType) - throws IOException { + Type targetType, Class> converterType) throws IOException { return inputMessage; } @@ -62,9 +62,8 @@ public abstract class RequestBodyAdviceAdapter implements RequestBodyAdvice { */ @Override @Nullable - public Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, - MethodParameter parameter, Type targetType, - Class> converterType) { + public Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, MethodParameter parameter, + Type targetType, Class> converterType) { return body; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java index 1bff038dbd1..51e1ddf5d3b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerIntegrationTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.resource; import java.io.IOException; @@ -49,6 +50,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments; /** * Integration tests for static resource handling. + * * @author Rossen Stoyanchev */ public class ResourceHttpRequestHandlerIntegrationTests { @@ -135,7 +137,7 @@ public class ResourceHttpRequestHandlerIntegrationTests { registerClasspathLocation("/cp/**", classPathLocation, registry); registerFileSystemLocation("/fs/**", path, registry); - registerUrlLocation("/url/**", "file://" + path, registry); + registerUrlLocation("/url/**", "file://" + path.replace('\\', '/'), registry); } protected void registerClasspathLocation(String pattern, ClassPathResource resource, ResourceHandlerRegistry registry) {