From 780993ce75a29003e54aea5d4f14b7496eda920a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 10 Nov 2017 20:21:26 +0100 Subject: [PATCH] Polishing --- .../http/client/Netty4ClientHttpRequest.java | 22 ++++++++----------- .../resource/PathResourceResolver.java | 5 ++--- .../resource/ResourceHttpRequestHandler.java | 10 ++++----- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java index 1d722a1ad48..387b1ec9ac0 100644 --- a/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java @@ -27,7 +27,6 @@ import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; @@ -115,18 +114,15 @@ class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements protected ListenableFuture executeInternal(final HttpHeaders headers) throws IOException { final SettableListenableFuture responseFuture = new SettableListenableFuture<>(); - ChannelFutureListener connectionListener = new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture future) throws Exception { - if (future.isSuccess()) { - Channel channel = future.channel(); - channel.pipeline().addLast(new RequestExecuteHandler(responseFuture)); - FullHttpRequest nettyRequest = createFullHttpRequest(headers); - channel.writeAndFlush(nettyRequest); - } - else { - responseFuture.setException(future.cause()); - } + ChannelFutureListener connectionListener = future -> { + if (future.isSuccess()) { + Channel channel = future.channel(); + channel.pipeline().addLast(new RequestExecuteHandler(responseFuture)); + FullHttpRequest nettyRequest = createFullHttpRequest(headers); + channel.writeAndFlush(nettyRequest); + } + else { + responseFuture.setException(future.cause()); } }; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java index db9c283c1c6..7543d91d4f6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/PathResourceResolver.java @@ -93,7 +93,6 @@ public class PathResourceResolver extends AbstractResourceResolver { *

Note: the charset is used only if the * {@link #setUrlPathHelper urlPathHelper} property is also configured and * its {@code urlDecode} property is set to true. - * @param locationCharsets charsets by location * @since 4.3.13 */ public void setLocationCharsets(Map locationCharsets) { @@ -106,14 +105,13 @@ public class PathResourceResolver extends AbstractResourceResolver { * @since 4.3.13 */ public Map getLocationCharsets() { - return Collections.unmodifiableMap(locationCharsets); + return Collections.unmodifiableMap(this.locationCharsets); } /** * Provide a reference to the {@link UrlPathHelper} used to map requests to * static resources. This helps to derive information about the lookup path * such as whether it is decoded or not. - * @param urlPathHelper a reference to the path helper * @since 4.3.13 */ public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) { @@ -129,6 +127,7 @@ public class PathResourceResolver extends AbstractResourceResolver { return this.urlPathHelper; } + @Override protected Resource resolveResourceInternal(@Nullable HttpServletRequest request, String requestPath, List locations, ResourceResolverChain chain) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java index 83f6d4423c5..15791b8ac9d 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandler.java @@ -153,13 +153,12 @@ public class ResourceHttpRequestHandler extends WebContentGenerator * {@link org.springframework.core.io.UrlResource URL resources} such as a * file or an HTTP URL location and is used in {@link PathResourceResolver} * to correctly encode paths relative to the location. - *

Note: the charset is used only if the + *

Note: The charset is used only if the * {@link #setUrlPathHelper urlPathHelper} property is also configured and - * its {@code urlDecode} property is set to true. - * @param locationCharsets charsets by location + * its {@code urlDecode} property is set to {@code true}. * @since 4.3.13 */ - public void setLocationCharsets(Map locationCharsets) { + public void setLocationCharsets(Map locationCharsets) { this.locationCharsets.clear(); this.locationCharsets.putAll(locationCharsets); } @@ -169,7 +168,7 @@ public class ResourceHttpRequestHandler extends WebContentGenerator * @since 4.3.13 */ public Map getLocationCharsets() { - return Collections.unmodifiableMap(locationCharsets); + return Collections.unmodifiableMap(this.locationCharsets); } /** @@ -286,7 +285,6 @@ public class ResourceHttpRequestHandler extends WebContentGenerator * Provide a reference to the {@link UrlPathHelper} used to map requests to * static resources. This helps to derive information about the lookup path * such as whether it is decoded or not. - * @param urlPathHelper a reference to the path helper * @since 4.3.13 */ public void setUrlPathHelper(@Nullable UrlPathHelper urlPathHelper) {