diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java index c9e0db6ad8..5ba7068f41 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinition.java @@ -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 Prototype, with an independent instance * returned for each call. + * @since 3.0 * @see #SCOPE_PROTOTYPE */ boolean isPrototype(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 4c93eae615..2bc2f7f89b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -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); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java index a7f7cf9f56..0103450e52 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/AbstractExceptionHandlerMethodResolver.java @@ -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(); } /** diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java index 2966a290c6..e28577c875 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java @@ -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); } diff --git a/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java index 48756e854a..9d5b598e48 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java @@ -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. - *
Default implementation returns: + *
The default implementation returns: *
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 diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableProcessingInterceptor.java b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableProcessingInterceptor.java index e180931685..a96c3538de 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/CallableProcessingInterceptor.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/CallableProcessingInterceptor.java @@ -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. * - *
The {@link #handleTimeout(NativeWebRequest, Callable) afterTimeout} method + *
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 before the start of concurrent handling in the original diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java index c121f575bf..ac2ca82de6 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolver.java @@ -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; } diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java index 999178f6fa..98032176eb 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java @@ -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 {