Skip to content

Commit d765698

Browse files
committed
Polishing
1 parent d081a45 commit d765698

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ListenableFutureCallbackRegistry<T> {
4242

4343

4444
/**
45-
* Adds the given callback to this registry.
45+
* Add the given callback to this registry.
4646
* @param callback the callback to add
4747
*/
4848
@SuppressWarnings("unchecked")
@@ -64,7 +64,7 @@ public void addCallback(ListenableFutureCallback<? super T> callback) {
6464
}
6565

6666
/**
67-
* Triggers a {@link ListenableFutureCallback#onSuccess(Object)} call on all
67+
* Trigger a {@link ListenableFutureCallback#onSuccess(Object)} call on all
6868
* added callbacks with the given result.
6969
* @param result the result to trigger the callbacks with
7070
*/
@@ -79,7 +79,7 @@ public void success(T result) {
7979
}
8080

8181
/**
82-
* Triggers a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
82+
* Trigger a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
8383
* added callbacks with the given {@code Throwable}.
8484
* @param ex the exception to trigger the callbacks with
8585
*/

spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java

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

1919
import java.io.IOException;
2020
import java.util.concurrent.Callable;
21-
import java.util.concurrent.ExecutionException;
2221

2322
import org.junit.Test;
2423

@@ -30,7 +29,7 @@
3029
public class ListenableFutureTaskTests {
3130

3231
@Test
33-
public void success() throws ExecutionException, InterruptedException {
32+
public void success() throws Exception {
3433
final String s = "Hello World";
3534
Callable<String> callable = new Callable<String>() {
3635
@Override
@@ -53,7 +52,7 @@ public void onFailure(Throwable ex) {
5352
}
5453

5554
@Test
56-
public void failure() throws ExecutionException, InterruptedException {
55+
public void failure() throws Exception {
5756
final String s = "Hello World";
5857
Callable<String> callable = new Callable<String>() {
5958
@Override

spring-web/src/main/java/org/springframework/web/bind/support/WebRequestDataBinder.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -16,11 +16,8 @@
1616

1717
package org.springframework.web.bind.support;
1818

19-
import java.io.IOException;
2019
import java.util.List;
2120
import java.util.Map;
22-
23-
import javax.servlet.ServletException;
2421
import javax.servlet.http.HttpServletRequest;
2522
import javax.servlet.http.Part;
2623

@@ -73,7 +70,6 @@
7370
*/
7471
public class WebRequestDataBinder extends WebDataBinder {
7572

76-
7773
/**
7874
* Create a new WebRequestDataBinder instance, with default object name.
7975
* @param target the target object to bind onto (or {@code null}
@@ -115,8 +111,7 @@ public WebRequestDataBinder(Object target, String objectName) {
115111
*/
116112
public void bind(WebRequest request) {
117113
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
118-
119-
if (isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
114+
if (isMultipartRequest(request) && request instanceof NativeWebRequest) {
120115
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
121116
if (multipartRequest != null) {
122117
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
@@ -129,6 +124,15 @@ else if (ClassUtils.hasMethod(HttpServletRequest.class, "getParts")) {
129124
doBind(mpvs);
130125
}
131126

127+
/**
128+
* Check if the request is a multipart request (by checking its Content-Type header).
129+
* @param request request with parameters to bind
130+
*/
131+
private boolean isMultipartRequest(WebRequest request) {
132+
String contentType = request.getHeader("Content-Type");
133+
return (contentType != null && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
134+
}
135+
132136
/**
133137
* Treats errors as fatal.
134138
* <p>Use this method only if it's an error if the input isn't valid.
@@ -141,16 +145,6 @@ public void closeNoCatch() throws BindException {
141145
}
142146
}
143147

144-
/**
145-
* Check if the request is a multipart request (by checking its Content-Type header).
146-
*
147-
* @param request request with parameters to bind
148-
*/
149-
private boolean isMultipartRequest(WebRequest request) {
150-
String contentType = request.getHeader("Content-Type");
151-
return ((contentType != null) && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
152-
}
153-
154148

155149
/**
156150
* Encapsulate Part binding code for Servlet 3.0+ only containers.
@@ -160,12 +154,10 @@ private static class Servlet3MultipartHelper {
160154

161155
private final boolean bindEmptyMultipartFiles;
162156

163-
164157
public Servlet3MultipartHelper(boolean bindEmptyMultipartFiles) {
165158
this.bindEmptyMultipartFiles = bindEmptyMultipartFiles;
166159
}
167160

168-
169161
public void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {
170162
try {
171163
MultiValueMap<String, Part> map = new LinkedMultiValueMap<String, Part>();
@@ -184,14 +176,10 @@ public void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {
184176
}
185177
}
186178
}
187-
catch (IOException ex) {
188-
throw new MultipartException("Failed to get request parts", ex);
189-
}
190-
catch(ServletException ex) {
179+
catch (Exception ex) {
191180
throw new MultipartException("Failed to get request parts", ex);
192181
}
193182
}
194-
195183
}
196184

197185
}

0 commit comments

Comments
 (0)