Skip to content

Commit 0968e47

Browse files
committed
Polishing
1 parent 356eaef commit 0968e47

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.nio.charset.Charset;
2020
import java.util.Base64;
21-
2221
import javax.xml.bind.DatatypeConverter;
2322

2423
import org.springframework.lang.UsesJava8;
@@ -106,6 +105,7 @@ public static byte[] decode(byte[] src) {
106105
* @return the encoded byte array (or {@code null} if the input was {@code null})
107106
* @throws IllegalStateException if Base64 encoding between byte arrays is not
108107
* supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
108+
* @since 4.2.4
109109
*/
110110
public static byte[] encodeUrlSafe(byte[] src) {
111111
assertDelegateAvailable();
@@ -119,6 +119,7 @@ public static byte[] encodeUrlSafe(byte[] src) {
119119
* @return the original byte array (or {@code null} if the input was {@code null})
120120
* @throws IllegalStateException if Base64 encoding between byte arrays is not
121121
* supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime
122+
* @since 4.2.4
122123
*/
123124
public static byte[] decodeUrlSafe(byte[] src) {
124125
assertDelegateAvailable();
@@ -252,9 +253,11 @@ public byte[] decodeUrlSafe(byte[] src) {
252253

253254
static class CommonsCodecBase64Delegate implements Base64Delegate {
254255

255-
private final org.apache.commons.codec.binary.Base64 base64 = new org.apache.commons.codec.binary.Base64();
256+
private final org.apache.commons.codec.binary.Base64 base64 =
257+
new org.apache.commons.codec.binary.Base64();
256258

257-
private final org.apache.commons.codec.binary.Base64 base64UrlSafe = new org.apache.commons.codec.binary.Base64(0, null, true);
259+
private final org.apache.commons.codec.binary.Base64 base64UrlSafe =
260+
new org.apache.commons.codec.binary.Base64(0, null, true);
258261

259262
@Override
260263
public byte[] encode(byte[] src) {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
5454

5555
private static class ResourceUrlEncodingResponseWrapper extends HttpServletResponseWrapper {
5656

57-
private HttpServletRequest request;
57+
private final HttpServletRequest request;
5858

59-
/* Cache the index of the path within the DispatcherServlet mapping. */
59+
/* Cache the index of the path within the DispatcherServlet mapping */
6060
private Integer indexLookupPath;
6161

6262
public ResourceUrlEncodingResponseWrapper(HttpServletRequest request, HttpServletResponse wrapped) {
@@ -71,6 +71,7 @@ public String encodeURL(String url) {
7171
logger.debug("Request attribute exposing ResourceUrlProvider not found");
7272
return super.encodeURL(url);
7373
}
74+
7475
initIndexLookupPath(resourceUrlProvider);
7576
if (url.length() >= this.indexLookupPath) {
7677
String prefix = url.substring(0, this.indexLookupPath);
@@ -82,12 +83,13 @@ public String encodeURL(String url) {
8283
return super.encodeURL(prefix + lookupPath + suffix);
8384
}
8485
}
86+
8587
return super.encodeURL(url);
8688
}
8789

8890
private ResourceUrlProvider getResourceUrlProvider() {
89-
String name = ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR;
90-
return (ResourceUrlProvider) this.request.getAttribute(name);
91+
return (ResourceUrlProvider) this.request.getAttribute(
92+
ResourceUrlProviderExposingInterceptor.RESOURCE_URL_PROVIDER_ATTR);
9193
}
9294

9395
private void initIndexLookupPath(ResourceUrlProvider urlProvider) {
@@ -107,7 +109,7 @@ private void initIndexLookupPath(ResourceUrlProvider urlProvider) {
107109

108110
private int getQueryParamsIndex(String url) {
109111
int index = url.indexOf("?");
110-
return index > 0 ? index : url.length();
112+
return (index > 0 ? index : url.length());
111113
}
112114
}
113115

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -34,20 +34,19 @@ public class ResourceUrlProviderExposingInterceptor extends HandlerInterceptorAd
3434
/**
3535
* Name of the request attribute that holds the {@link ResourceUrlProvider}.
3636
*/
37-
public static final String RESOURCE_URL_PROVIDER_ATTR = ResourceUrlProvider.class.getName().toString();
38-
37+
public static final String RESOURCE_URL_PROVIDER_ATTR = ResourceUrlProvider.class.getName();
3938

4039
private final ResourceUrlProvider resourceUrlProvider;
4140

4241

4342
public ResourceUrlProviderExposingInterceptor(ResourceUrlProvider resourceUrlProvider) {
44-
Assert.notNull(resourceUrlProvider, "'resourceUrlProvider' is required");
43+
Assert.notNull(resourceUrlProvider, "ResourceUrlProvider is required");
4544
this.resourceUrlProvider = resourceUrlProvider;
4645
}
4746

4847
@Override
49-
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
50-
Object handler) throws Exception {
48+
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
49+
throws Exception {
5150

5251
request.setAttribute(RESOURCE_URL_PROVIDER_ATTR, this.resourceUrlProvider);
5352
return true;

0 commit comments

Comments
 (0)