Polishing

This commit is contained in:
Juergen Hoeller
2016-05-06 12:03:10 +02:00
parent 42d32ba396
commit 5682950289
4 changed files with 27 additions and 19 deletions

View File

@@ -143,7 +143,7 @@ public abstract class StreamUtils {
* @param end the position to end copying
* @return the number of bytes copied
* @throws IOException in case of I/O errors
* @since 4.3.0
* @since 4.3
*/
public static long copyRange(InputStream in, OutputStream out, long start, long end) throws IOException {
long skipped = in.skip(start);
@@ -175,7 +175,7 @@ public abstract class StreamUtils {
* @param in the InputStream to drain
* @return the number of bytes read
* @throws IOException in case of I/O errors
* @since 4.3.0
* @since 4.3
*/
public static int drain(InputStream in) throws IOException {
Assert.notNull(in, "No InputStream specified");

View File

@@ -907,7 +907,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
/**
* Return all values of a given header name,
* even if this header is set multiple times.
* @since 4.3.0
* @since 4.3
*/
public List<String> getValuesAsList(String headerName) {
List<String> values = get(headerName);

View File

@@ -17,7 +17,6 @@
package org.springframework.web.filter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -90,7 +89,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
* override existing request encodings
* @param forceResponseEncoding whether the specified encoding is supposed to
* override existing response encodings
* @since 4.3.0
* @since 4.3
* @see #setEncoding
* @see #setForceRequestEncoding(boolean)
* @see #setForceResponseEncoding(boolean)
@@ -102,6 +101,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
this.forceResponseEncoding = forceResponseEncoding;
}
/**
* Set the encoding to use for requests. This encoding will be passed into a
* {@link javax.servlet.http.HttpServletRequest#setCharacterEncoding} call.
@@ -115,9 +115,10 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
/**
* Return the configured encoding for requests and/or responses
* @since 4.3
*/
public String getEncoding() {
return encoding;
return this.encoding;
}
/**
@@ -144,7 +145,7 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
* {@link javax.servlet.http.HttpServletRequest#getCharacterEncoding()}
* returns a non-null value. Switch this to "true" to enforce the specified
* encoding in any case.
* @since 4.3.0
* @since 4.3
*/
public void setForceRequestEncoding(boolean forceRequestEncoding) {
this.forceRequestEncoding = forceRequestEncoding;
@@ -152,9 +153,10 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
/**
* Return whether the encoding should be forced on requests
* @since 4.3
*/
public boolean isForceRequestEncoding() {
return forceRequestEncoding;
return this.forceRequestEncoding;
}
/**
@@ -163,29 +165,33 @@ public class CharacterEncodingFilter extends OncePerRequestFilter {
* <p>Default is "false", i.e. do not modify the encoding.
* Switch this to "true" to enforce the specified encoding
* for responses in any case.
* @since 4.3.0
* @since 4.3
*/
public void setForceResponseEncoding(boolean forceResponseEncoding) {
this.forceResponseEncoding = forceResponseEncoding;
}
/**
* Return whether the encoding should be forced on responses
* Return whether the encoding should be forced on responses.
* @since 4.3
*/
public boolean isForceResponseEncoding() {
return forceResponseEncoding;
return this.forceResponseEncoding;
}
@Override
protected void doFilterInternal(
HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
if (this.encoding != null) {
if (this.forceRequestEncoding || request.getCharacterEncoding() == null) {
request.setCharacterEncoding(this.encoding);
String encoding = getEncoding();
if (encoding != null) {
if (isForceRequestEncoding() || request.getCharacterEncoding() == null) {
request.setCharacterEncoding(encoding);
}
if (this.forceResponseEncoding) {
response.setCharacterEncoding(this.encoding);
if (isForceResponseEncoding()) {
response.setCharacterEncoding(encoding);
}
}
filterChain.doFilter(request, response);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -17,7 +17,6 @@
package org.springframework.web.servlet.resource;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.webjars.MultipleMatchesException;
@@ -50,8 +49,10 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
private final static int WEBJARS_LOCATION_LENGTH = WEBJARS_LOCATION.length();
private final WebJarAssetLocator webJarAssetLocator;
/**
* Create a {@code WebJarsResourceResolver} with a default {@code WebJarAssetLocator} instance.
*/
@@ -62,12 +63,13 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
/**
* Create a {@code WebJarsResourceResolver} with a custom {@code WebJarAssetLocator} instance,
* e.g. with a custom index.
* @since 4.3.0
* @since 4.3
*/
public WebJarsResourceResolver(WebJarAssetLocator webJarAssetLocator) {
this.webJarAssetLocator = webJarAssetLocator;
}
@Override
protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath,
List<? extends Resource> locations, ResourceResolverChain chain) {