Polishing

This commit is contained in:
Juergen Hoeller
2014-09-04 03:06:37 +02:00
parent d081a4530c
commit d765698ac3
3 changed files with 17 additions and 30 deletions

View File

@@ -42,7 +42,7 @@ public class ListenableFutureCallbackRegistry<T> {
/**
* Adds the given callback to this registry.
* Add the given callback to this registry.
* @param callback the callback to add
*/
@SuppressWarnings("unchecked")
@@ -64,7 +64,7 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Triggers a {@link ListenableFutureCallback#onSuccess(Object)} call on all
* Trigger a {@link ListenableFutureCallback#onSuccess(Object)} call on all
* added callbacks with the given result.
* @param result the result to trigger the callbacks with
*/
@@ -79,7 +79,7 @@ public class ListenableFutureCallbackRegistry<T> {
}
/**
* Triggers a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
* Trigger a {@link ListenableFutureCallback#onFailure(Throwable)} call on all
* added callbacks with the given {@code Throwable}.
* @param ex the exception to trigger the callbacks with
*/

View File

@@ -18,7 +18,6 @@ package org.springframework.util.concurrent;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
@@ -30,7 +29,7 @@ import static org.junit.Assert.*;
public class ListenableFutureTaskTests {
@Test
public void success() throws ExecutionException, InterruptedException {
public void success() throws Exception {
final String s = "Hello World";
Callable<String> callable = new Callable<String>() {
@Override
@@ -53,7 +52,7 @@ public class ListenableFutureTaskTests {
}
@Test
public void failure() throws ExecutionException, InterruptedException {
public void failure() throws Exception {
final String s = "Hello World";
Callable<String> callable = new Callable<String>() {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -16,11 +16,8 @@
package org.springframework.web.bind.support;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
@@ -73,7 +70,6 @@ import org.springframework.web.multipart.MultipartRequest;
*/
public class WebRequestDataBinder extends WebDataBinder {
/**
* Create a new WebRequestDataBinder instance, with default object name.
* @param target the target object to bind onto (or {@code null}
@@ -115,8 +111,7 @@ public class WebRequestDataBinder extends WebDataBinder {
*/
public void bind(WebRequest request) {
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
if (isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
if (isMultipartRequest(request) && request instanceof NativeWebRequest) {
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
if (multipartRequest != null) {
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
@@ -129,6 +124,15 @@ public class WebRequestDataBinder extends WebDataBinder {
doBind(mpvs);
}
/**
* Check if the request is a multipart request (by checking its Content-Type header).
* @param request request with parameters to bind
*/
private boolean isMultipartRequest(WebRequest request) {
String contentType = request.getHeader("Content-Type");
return (contentType != null && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
}
/**
* Treats errors as fatal.
* <p>Use this method only if it's an error if the input isn't valid.
@@ -141,16 +145,6 @@ public class WebRequestDataBinder extends WebDataBinder {
}
}
/**
* Check if the request is a multipart request (by checking its Content-Type header).
*
* @param request request with parameters to bind
*/
private boolean isMultipartRequest(WebRequest request) {
String contentType = request.getHeader("Content-Type");
return ((contentType != null) && StringUtils.startsWithIgnoreCase(contentType, "multipart"));
}
/**
* Encapsulate Part binding code for Servlet 3.0+ only containers.
@@ -160,12 +154,10 @@ public class WebRequestDataBinder extends WebDataBinder {
private final boolean bindEmptyMultipartFiles;
public Servlet3MultipartHelper(boolean bindEmptyMultipartFiles) {
this.bindEmptyMultipartFiles = bindEmptyMultipartFiles;
}
public void bindParts(HttpServletRequest request, MutablePropertyValues mpvs) {
try {
MultiValueMap<String, Part> map = new LinkedMultiValueMap<String, Part>();
@@ -184,14 +176,10 @@ public class WebRequestDataBinder extends WebDataBinder {
}
}
}
catch (IOException ex) {
throw new MultipartException("Failed to get request parts", ex);
}
catch(ServletException ex) {
catch (Exception ex) {
throw new MultipartException("Failed to get request parts", ex);
}
}
}
}