Skip to content

Commit 5682950

Browse files
committed
Polishing
1 parent 42d32ba commit 5682950

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

spring-core/src/main/java/org/springframework/util/StreamUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public static int copy(InputStream in, OutputStream out) throws IOException {
143143
* @param end the position to end copying
144144
* @return the number of bytes copied
145145
* @throws IOException in case of I/O errors
146-
* @since 4.3.0
146+
* @since 4.3
147147
*/
148148
public static long copyRange(InputStream in, OutputStream out, long start, long end) throws IOException {
149149
long skipped = in.skip(start);
@@ -175,7 +175,7 @@ else if (bytesRead <= bytesToCopy) {
175175
* @param in the InputStream to drain
176176
* @return the number of bytes read
177177
* @throws IOException in case of I/O errors
178-
* @since 4.3.0
178+
* @since 4.3
179179
*/
180180
public static int drain(InputStream in) throws IOException {
181181
Assert.notNull(in, "No InputStream specified");

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ public List<String> getIfNoneMatch() {
907907
/**
908908
* Return all values of a given header name,
909909
* even if this header is set multiple times.
910-
* @since 4.3.0
910+
* @since 4.3
911911
*/
912912
public List<String> getValuesAsList(String headerName) {
913913
List<String> values = get(headerName);

spring-web/src/main/java/org/springframework/web/filter/CharacterEncodingFilter.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.web.filter;
1818

1919
import java.io.IOException;
20-
2120
import javax.servlet.FilterChain;
2221
import javax.servlet.ServletException;
2322
import javax.servlet.http.HttpServletRequest;
@@ -90,7 +89,7 @@ public CharacterEncodingFilter(String encoding, boolean forceEncoding) {
9089
* override existing request encodings
9190
* @param forceResponseEncoding whether the specified encoding is supposed to
9291
* override existing response encodings
93-
* @since 4.3.0
92+
* @since 4.3
9493
* @see #setEncoding
9594
* @see #setForceRequestEncoding(boolean)
9695
* @see #setForceResponseEncoding(boolean)
@@ -102,6 +101,7 @@ public CharacterEncodingFilter(String encoding, boolean forceRequestEncoding, bo
102101
this.forceResponseEncoding = forceResponseEncoding;
103102
}
104103

104+
105105
/**
106106
* Set the encoding to use for requests. This encoding will be passed into a
107107
* {@link javax.servlet.http.HttpServletRequest#setCharacterEncoding} call.
@@ -115,9 +115,10 @@ public void setEncoding(String encoding) {
115115

116116
/**
117117
* Return the configured encoding for requests and/or responses
118+
* @since 4.3
118119
*/
119120
public String getEncoding() {
120-
return encoding;
121+
return this.encoding;
121122
}
122123

123124
/**
@@ -144,17 +145,18 @@ public void setForceEncoding(boolean forceEncoding) {
144145
* {@link javax.servlet.http.HttpServletRequest#getCharacterEncoding()}
145146
* returns a non-null value. Switch this to "true" to enforce the specified
146147
* encoding in any case.
147-
* @since 4.3.0
148+
* @since 4.3
148149
*/
149150
public void setForceRequestEncoding(boolean forceRequestEncoding) {
150151
this.forceRequestEncoding = forceRequestEncoding;
151152
}
152153

153154
/**
154155
* Return whether the encoding should be forced on requests
156+
* @since 4.3
155157
*/
156158
public boolean isForceRequestEncoding() {
157-
return forceRequestEncoding;
159+
return this.forceRequestEncoding;
158160
}
159161

160162
/**
@@ -163,29 +165,33 @@ public boolean isForceRequestEncoding() {
163165
* <p>Default is "false", i.e. do not modify the encoding.
164166
* Switch this to "true" to enforce the specified encoding
165167
* for responses in any case.
166-
* @since 4.3.0
168+
* @since 4.3
167169
*/
168170
public void setForceResponseEncoding(boolean forceResponseEncoding) {
169171
this.forceResponseEncoding = forceResponseEncoding;
170172
}
171173

172174
/**
173-
* Return whether the encoding should be forced on responses
175+
* Return whether the encoding should be forced on responses.
176+
* @since 4.3
174177
*/
175178
public boolean isForceResponseEncoding() {
176-
return forceResponseEncoding;
179+
return this.forceResponseEncoding;
177180
}
178181

182+
179183
@Override
180184
protected void doFilterInternal(
181185
HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
182186
throws ServletException, IOException {
183-
if (this.encoding != null) {
184-
if (this.forceRequestEncoding || request.getCharacterEncoding() == null) {
185-
request.setCharacterEncoding(this.encoding);
187+
188+
String encoding = getEncoding();
189+
if (encoding != null) {
190+
if (isForceRequestEncoding() || request.getCharacterEncoding() == null) {
191+
request.setCharacterEncoding(encoding);
186192
}
187-
if (this.forceResponseEncoding) {
188-
response.setCharacterEncoding(this.encoding);
193+
if (isForceResponseEncoding()) {
194+
response.setCharacterEncoding(encoding);
189195
}
190196
}
191197
filterChain.doFilter(request, response);

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.web.servlet.resource;
1818

1919
import java.util.List;
20-
2120
import javax.servlet.http.HttpServletRequest;
2221

2322
import org.webjars.MultipleMatchesException;
@@ -50,8 +49,10 @@ public class WebJarsResourceResolver extends AbstractResourceResolver {
5049

5150
private final static int WEBJARS_LOCATION_LENGTH = WEBJARS_LOCATION.length();
5251

52+
5353
private final WebJarAssetLocator webJarAssetLocator;
5454

55+
5556
/**
5657
* Create a {@code WebJarsResourceResolver} with a default {@code WebJarAssetLocator} instance.
5758
*/
@@ -62,12 +63,13 @@ public WebJarsResourceResolver() {
6263
/**
6364
* Create a {@code WebJarsResourceResolver} with a custom {@code WebJarAssetLocator} instance,
6465
* e.g. with a custom index.
65-
* @since 4.3.0
66+
* @since 4.3
6667
*/
6768
public WebJarsResourceResolver(WebJarAssetLocator webJarAssetLocator) {
6869
this.webJarAssetLocator = webJarAssetLocator;
6970
}
7071

72+
7173
@Override
7274
protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath,
7375
List<? extends Resource> locations, ResourceResolverChain chain) {

0 commit comments

Comments
 (0)