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) 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: *