Polishing

This commit is contained in:
Juergen Hoeller
2017-09-08 19:42:32 +02:00
parent fa2c377405
commit 17f42fc97a
8 changed files with 47 additions and 24 deletions

View File

@@ -201,8 +201,8 @@ public class WebDataBinder extends DataBinder {
* @see #getFieldDefaultPrefix
*/
protected void checkFieldDefaults(MutablePropertyValues mpvs) {
if (getFieldDefaultPrefix() != null) {
String fieldDefaultPrefix = getFieldDefaultPrefix();
String fieldDefaultPrefix = getFieldDefaultPrefix();
if (fieldDefaultPrefix != null) {
PropertyValue[] pvArray = mpvs.getPropertyValues();
for (PropertyValue pv : pvArray) {
if (pv.getName().startsWith(fieldDefaultPrefix)) {
@@ -228,8 +228,8 @@ public class WebDataBinder extends DataBinder {
* @see #getEmptyValue(String, Class)
*/
protected void checkFieldMarkers(MutablePropertyValues mpvs) {
if (getFieldMarkerPrefix() != null) {
String fieldMarkerPrefix = getFieldMarkerPrefix();
String fieldMarkerPrefix = getFieldMarkerPrefix();
if (fieldMarkerPrefix != null) {
PropertyValue[] pvArray = mpvs.getPropertyValues();
for (PropertyValue pv : pvArray) {
if (pv.getName().startsWith(fieldMarkerPrefix)) {
@@ -246,7 +246,7 @@ public class WebDataBinder extends DataBinder {
/**
* Determine an empty value for the specified field.
* <p>Default implementation returns:
* <p>The default implementation returns:
* <ul>
* <li>{@code Boolean.FALSE} for boolean fields
* <li>an empty array for array types
@@ -275,17 +275,20 @@ public class WebDataBinder extends DataBinder {
else if (Map.class.isAssignableFrom(fieldType)) {
return CollectionFactory.createMap(fieldType, 0);
}
} catch (IllegalArgumentException exc) {
return null;
}
catch (IllegalArgumentException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to create default value - falling back to null: " + ex.getMessage());
}
}
}
// Default value: try null.
// Default value: null.
return null;
}
/**
* Bind all multipart files contained in the given request, if any
* (in case of a multipart request).
* (in case of a multipart request). To be called by subclasses.
* <p>Multipart files will only be added to the property values if they
* are not empty or if we're configured to bind empty multipart files too.
* @param multipartFiles Map of field name String to MultipartFile object

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@@ -36,7 +36,7 @@ import org.springframework.web.context.request.NativeWebRequest;
* the Exception instance as the concurrent result. Such exceptions will then
* be processed through the {@code HandlerExceptionResolver} mechanism.
*
* <p>The {@link #handleTimeout(NativeWebRequest, Callable) afterTimeout} method
* <p>The {@link #handleTimeout(NativeWebRequest, Callable) handleTimeout} method
* can select a value to be used to resume processing.
*
* @author Rossen Stoyanchev
@@ -45,9 +45,20 @@ import org.springframework.web.context.request.NativeWebRequest;
*/
public interface CallableProcessingInterceptor {
static final Object RESULT_NONE = new Object();
/**
* Constant indicating that no result has been determined by this
* interceptor, giving subsequent interceptors a chance.
* @see #handleTimeout
*/
Object RESULT_NONE = new Object();
/**
* Constant indicating that the response has been handled by this interceptor
* without a result and that no further interceptors are to be invoked.
* @see #handleTimeout
*/
Object RESPONSE_HANDLED = new Object();
static final Object RESPONSE_HANDLED = new Object();
/**
* Invoked <em>before</em> the start of concurrent handling in the original

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -94,7 +94,9 @@ public class ExceptionHandlerMethodResolver {
}
}
}
Assert.notEmpty(result, "No exception types mapped to {" + method + "}");
if (result.isEmpty()) {
throw new IllegalStateException("No exception types mapped to " + method);
}
return result;
}