diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java index 080e6f8b5b..56906cd8e2 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java @@ -165,8 +165,8 @@ public abstract class AbstractSchedulingTaskExecutorTests { TestCallable task2 = new TestCallable(-1); Future future2 = executor.submit(task2); shutdownExecutor(); - future1.get(); - future2.get(); + future1.get(100, TimeUnit.MILLISECONDS); + future2.get(100, TimeUnit.MILLISECONDS); } @Test @@ -196,8 +196,8 @@ public abstract class AbstractSchedulingTaskExecutorTests { TestCallable task2 = new TestCallable(-1); ListenableFuture future2 = executor.submitListenable(task2); shutdownExecutor(); - future1.get(); - future2.get(); + future1.get(100, TimeUnit.MILLISECONDS); + future2.get(100, TimeUnit.MILLISECONDS); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index 238f11c407..26ac630d24 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -592,7 +592,8 @@ public abstract class AnnotationUtils { } static Set getAnnotatedMethodsInBaseType(Class baseType) { - if (ClassUtils.isJavaLanguageInterface(baseType)) { + boolean ifcCheck = baseType.isInterface(); + if (ifcCheck && ClassUtils.isJavaLanguageInterface(baseType)) { return Collections.emptySet(); } @@ -600,10 +601,13 @@ public abstract class AnnotationUtils { if (annotatedMethods != null) { return annotatedMethods; } - Method[] methods = (baseType.isInterface() ? baseType.getMethods() : baseType.getDeclaredMethods()); + Method[] methods = (ifcCheck ? baseType.getMethods() : baseType.getDeclaredMethods()); for (Method baseMethod : methods) { try { - if (hasSearchableAnnotations(baseMethod)) { + // Public methods on interfaces (including interface hierarchy), + // non-private (and therefore overridable) methods on base classes + if ((ifcCheck || !Modifier.isPrivate(baseMethod.getModifiers())) && + hasSearchableAnnotations(baseMethod)) { if (annotatedMethods == null) { annotatedMethods = new HashSet<>(); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 9bc555947d..76ea099043 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -711,7 +711,7 @@ public class AnnotationUtilsTests { public void getAttributeOverrideNameFromWrongTargetAnnotation() throws Exception { Method attribute = AliasedComposedContextConfig.class.getDeclaredMethod("xmlConfigFile"); assertThat("xmlConfigFile is not an alias for @Component.", - getAttributeOverrideName(attribute, Component.class), is(nullValue())); + getAttributeOverrideName(attribute, Component.class), is(nullValue())); } @Test @@ -905,7 +905,6 @@ public class AnnotationUtilsTests { public void synthesizeAnnotationWithAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception { AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation(AliasForWithMirroredAliasForWrongAttribute.class); - exception.expect(AnnotationConfigurationException.class); exception.expectMessage(startsWith("Attribute 'bar' in")); exception.expectMessage(containsString(AliasForWithMirroredAliasForWrongAttribute.class.getName())); @@ -1013,18 +1012,18 @@ public class AnnotationUtilsTests { @Test public void synthesizeAnnotationWithImplicitAliasesWithImpliedAliasNamesOmitted() throws Exception { assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( - ValueImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "value"); + ValueImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "value"); assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( - LocationsImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "location"); + LocationsImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "location"); assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( - XmlFilesImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "xmlFile"); + XmlFilesImplicitAliasesWithImpliedAliasNamesOmittedContextConfigClass.class, "xmlFile"); } - private void assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted(Class clazz, - String expected) throws Exception { + private void assertAnnotationSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( + Class clazz, String expected) { ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig config = clazz.getAnnotation( - ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig.class); + ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig.class); assertNotNull(config); ImplicitAliasesWithImpliedAliasNamesOmittedContextConfig synthesizedConfig = synthesizeAnnotation(config); @@ -1222,7 +1221,6 @@ public class AnnotationUtilsTests { @Test public void synthesizeAnnotationWithAttributeAliasesWithDifferentValues() throws Exception { ContextConfig contextConfig = synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)); - exception.expect(AnnotationConfigurationException.class); getValue(contextConfig); } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java index a1a33f21ff..6c503adf5d 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java @@ -89,6 +89,7 @@ public final class MockMvc { Assert.notNull(servlet, "DispatcherServlet is required"); Assert.notNull(filters, "Filters cannot be null"); Assert.noNullElements(filters, "Filters cannot contain null values"); + this.servlet = servlet; this.filters = filters; this.servletContext = servlet.getServletContext(); @@ -201,7 +202,6 @@ public final class MockMvc { for (ResultMatcher matcher : this.defaultResultMatchers) { matcher.match(mvcResult); } - for (ResultHandler handler : this.defaultResultHandlers) { handler.handle(mvcResult); } diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index 8243e1dd4a..1bb2081a7a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -268,7 +268,7 @@ public class UrlPathHelper { } c1 = requestUri.charAt(index1); } - if (c1 == c2 || ignoreCase && (Character.toLowerCase(c1) == Character.toLowerCase(c2))) { + if (c1 == c2 || (ignoreCase && (Character.toLowerCase(c1) == Character.toLowerCase(c2)))) { continue; } return null; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java index 792a67d22b..f9783feaf8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java @@ -63,7 +63,7 @@ import org.springframework.web.servlet.View; public class ResourceBundleViewResolver extends AbstractCachingViewResolver implements Ordered, InitializingBean, DisposableBean { - /** The default basename if no other basename is supplied. */ + /** The default basename if no other basename is supplied */ public static final String DEFAULT_BASENAME = "views"; @@ -77,14 +77,14 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver @Nullable private Locale[] localesToInitialize; + private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered + /* Locale -> BeanFactory */ private final Map localeCache = new HashMap<>(); /* List of ResourceBundle -> BeanFactory */ private final Map, ConfigurableApplicationContext> bundleCache = new HashMap<>(); - private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered - /** * Set a single basename, following {@link java.util.ResourceBundle} conventions. @@ -97,7 +97,8 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver * This means that "test.theme" is effectively equivalent to "test/theme", * just like it is for programmatic {@code java.util.ResourceBundle} usage. * @see #setBasenames - * @see java.util.ResourceBundle#getBundle(String) + * @see ResourceBundle#getBundle(String) + * @see ResourceBundle#getBundle(String, Locale) */ public void setBasename(String basename) { setBasenames(basename); @@ -118,7 +119,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver * This means that "test.theme" is effectively equivalent to "test/theme", * just like it is for programmatic {@code java.util.ResourceBundle} usage. * @see #setBasename - * @see java.util.ResourceBundle#getBundle(String) + * @see ResourceBundle#getBundle(String) */ public void setBasenames(String... basenames) { this.basenames = basenames; @@ -271,7 +272,7 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver * @param locale the {@code Locale} to look for * @return the corresponding {@code ResourceBundle} * @throws MissingResourceException if no matching bundle could be found - * @see java.util.ResourceBundle#getBundle(String, java.util.Locale, ClassLoader) + * @see ResourceBundle#getBundle(String, Locale, ClassLoader) */ protected ResourceBundle getBundle(String basename, Locale locale) throws MissingResourceException { return ResourceBundle.getBundle(basename, locale, getBundleClassLoader());