Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -232,6 +232,7 @@ public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
|
||||
/**
|
||||
* Return whether this a <b>Prototype</b>, with an independent instance
|
||||
* returned for each call.
|
||||
* @since 3.0
|
||||
* @see #SCOPE_PROTOTYPE
|
||||
*/
|
||||
boolean isPrototype();
|
||||
|
||||
@@ -366,7 +366,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
||||
}
|
||||
|
||||
// Check if required type matches the type of the actual bean instance.
|
||||
if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
|
||||
if (requiredType != null && bean != null && !requiredType.isInstance(bean)) {
|
||||
try {
|
||||
return getTypeConverter().convertIfNecessary(bean, requiredType);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -66,7 +66,9 @@ public abstract class AbstractExceptionHandlerMethodResolver {
|
||||
result.add((Class<? extends Throwable>) paramType);
|
||||
}
|
||||
}
|
||||
Assert.notEmpty(result, "No exception types mapped to {" + method + "}");
|
||||
if (result.isEmpty()) {
|
||||
throw new IllegalStateException("No exception types mapped to " + method);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -75,7 +77,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
|
||||
* Whether the contained type has any exception mappings.
|
||||
*/
|
||||
public boolean hasExceptionMappings() {
|
||||
return (this.mappedMethods.size() > 0);
|
||||
return !this.mappedMethods.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,7 @@ public class AnnotationExceptionHandlerMethodResolverTests {
|
||||
new AnnotationExceptionHandlerMethodResolver(AmbiguousController.class);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void noExceptionMapping() {
|
||||
new AnnotationExceptionHandlerMethodResolver(NoExceptionController.class);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -88,11 +88,12 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
new ExceptionHandlerMethodResolver(AmbiguousController.class);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void noExceptionMapping() {
|
||||
new ExceptionHandlerMethodResolver(NoExceptionController.class);
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
static class ExceptionController {
|
||||
|
||||
@@ -111,6 +112,7 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
static class InheritedController extends ExceptionController {
|
||||
|
||||
@@ -119,6 +121,7 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
static class AmbiguousController {
|
||||
|
||||
@@ -136,6 +139,7 @@ public class ExceptionHandlerMethodResolverTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Controller
|
||||
static class NoExceptionController {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user