diff --git a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java index 8e539bade4..b268b119b5 100644 --- a/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java +++ b/spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java @@ -71,7 +71,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar server.registerMBean(new LiveBeansView(), new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName)); } - catch (Exception ex) { + catch (Throwable ex) { throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex); } } @@ -88,7 +88,7 @@ public class LiveBeansView implements LiveBeansViewMBean, ApplicationContextAwar String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME); server.unregisterMBean(new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName)); } - catch (Exception ex) { + catch (Throwable ex) { throw new ApplicationContextException("Failed to unregister LiveBeansView MBean", ex); } finally { applicationName = null; diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java index 48efe37957..19380bf49e 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java @@ -82,6 +82,7 @@ public class CustomNamespaceHandlerTests { private GenericApplicationContext beanFactory; + @Before public void setUp() throws Exception { NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS); @@ -148,30 +149,21 @@ public class CustomNamespaceHandlerTests { assertEquals("foo", beanDefinition.getAttribute("objectName")); } - /** - * http://opensource.atlassian.com/projects/spring/browse/SPR-2728 - */ - @Test + @Test // SPR-2728 public void testCustomElementNestedWithinUtilList() throws Exception { List> things = (List>) this.beanFactory.getBean("list.of.things"); assertNotNull(things); assertEquals(2, things.size()); } - /** - * http://opensource.atlassian.com/projects/spring/browse/SPR-2728 - */ - @Test + @Test // SPR-2728 public void testCustomElementNestedWithinUtilSet() throws Exception { Set> things = (Set>) this.beanFactory.getBean("set.of.things"); assertNotNull(things); assertEquals(2, things.size()); } - /** - * http://opensource.atlassian.com/projects/spring/browse/SPR-2728 - */ - @Test + @Test // SPR-2728 public void testCustomElementNestedWithinUtilMap() throws Exception { Map, ?> things = (Map, ?>) this.beanFactory.getBean("map.of.things"); assertNotNull(things); @@ -229,6 +221,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { registerBeanDefinitionDecoratorForAttribute("object-name", new ObjectNameBeanDefinitionDecorator()); } + private static class TestBeanDefinitionParser implements BeanDefinitionParser { @Override @@ -247,6 +240,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { } } + private static final class PersonDefinitionParser extends AbstractSingleBeanDefinitionParser { @Override @@ -261,6 +255,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { } } + private static class PropertyModifyingBeanDefinitionDecorator implements BeanDefinitionDecorator { @Override @@ -277,6 +272,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { } } + private static class DebugBeanDefinitionDecorator extends AbstractInterceptorDrivenBeanDefinitionDecorator { @Override @@ -285,6 +281,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { } } + private static class NopInterceptorBeanDefinitionDecorator extends AbstractInterceptorDrivenBeanDefinitionDecorator { @Override @@ -293,6 +290,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { } } + private static class ObjectNameBeanDefinitionDecorator implements BeanDefinitionDecorator { @Override @@ -302,5 +300,5 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport { return definition; } } -} +} diff --git a/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java b/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java index 73c9b158b2..7f1c730517 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/EncodedResource.java @@ -37,6 +37,7 @@ import org.springframework.util.ObjectUtils; * @author Juergen Hoeller * @author Sam Brannen * @since 1.2.6 + * @see Resource#getInputStream() * @see java.io.Reader * @see java.nio.charset.Charset */ @@ -142,8 +143,8 @@ public class EncodedResource implements InputStreamSource { } /** - * Open a {@code java.io.InputStream} for the specified resource, ignoring any - * specified {@link #getCharset() Charset} or {@linkplain #getEncoding() encoding}. + * Open an {@code InputStream} for the specified resource, ignoring any specified + * {@link #getCharset() Charset} or {@linkplain #getEncoding() encoding}. * @throws IOException if opening the InputStream failed * @see #requiresReader() * @see #getReader() diff --git a/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java b/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java index 66be13072e..0144f65d79 100644 --- a/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java +++ b/spring-core/src/test/java/org/springframework/tests/TestResourceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2016 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. @@ -18,29 +18,22 @@ package org.springframework.tests; import org.springframework.core.io.ClassPathResource; -import static java.lang.String.*; - /** * Convenience utilities for common operations with test resources. * * @author Chris Beams */ -public class TestResourceUtils { +public abstract class TestResourceUtils { /** - * Loads a {@link ClassPathResource} qualified by the simple name of clazz, + * Load a {@link ClassPathResource} qualified by the simple name of clazz, * and relative to the package for clazz. - * *
Example: given a clazz 'com.foo.BarTests' and a resourceSuffix of 'context.xml', * this method will return a ClassPathResource representing com/foo/BarTests-context.xml - * *
Intended for use loading context configuration XML files within JUnit tests.
- *
- * @param clazz
- * @param resourceSuffix
*/
public static ClassPathResource qualifiedResource(Class> clazz, String resourceSuffix) {
- return new ClassPathResource(format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz);
+ return new ClassPathResource(String.format("%s-%s", clazz.getSimpleName(), resourceSuffix), clazz);
}
}
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
index 31fb497c8a..e153f3790d 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2016 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.
@@ -40,8 +40,8 @@ public abstract class DatabasePopulatorUtils {
* @throws DataAccessException if an error occurs, specifically a {@link ScriptException}
*/
public static void execute(DatabasePopulator populator, DataSource dataSource) throws DataAccessException {
- Assert.notNull(populator, "DatabasePopulator must be provided");
- Assert.notNull(dataSource, "DataSource must be provided");
+ Assert.notNull(populator, "DatabasePopulator must not be null");
+ Assert.notNull(dataSource, "DataSource must not be null");
try {
Connection connection = DataSourceUtils.getConnection(dataSource);
try {
@@ -53,11 +53,10 @@ public abstract class DatabasePopulatorUtils {
}
}
}
- catch (Exception ex) {
+ catch (Throwable ex) {
if (ex instanceof ScriptException) {
throw (ScriptException) ex;
}
-
throw new UncategorizedScriptException("Failed to execute database script", ex);
}
}
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
index 75a668d516..513a9c6085 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
*/
public class ResourceDatabasePopulator implements DatabasePopulator {
- private List