#31 - Move away from deprecated assertion methods in Spring 5.

We now consistently use Assert.notNull(…) et al that take an error message as the overload without a message have been deprecated in Spring 5.

Added build profile for Spring 5 releases and snapshots.
This commit is contained in:
Oliver Gierke
2017-01-31 10:48:22 +01:00
parent 66eaf45b17
commit 2abef3aafc
4 changed files with 44 additions and 14 deletions

View File

@@ -40,7 +40,7 @@ public abstract class PluginRegistrySupport<T extends Plugin<S>, S> implements P
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public PluginRegistrySupport(List<? extends T> plugins) { public PluginRegistrySupport(List<? extends T> plugins) {
Assert.notNull(plugins); Assert.notNull(plugins, "Plugins must not be null!");
this.plugins = plugins == null ? new ArrayList<T>() : (List<T>) plugins; this.plugins = plugins == null ? new ArrayList<T>() : (List<T>) plugins;
this.initialized = false; this.initialized = false;
@@ -72,7 +72,7 @@ public abstract class PluginRegistrySupport<T extends Plugin<S>, S> implements P
*/ */
protected synchronized List<T> initialize(List<T> plugins) { protected synchronized List<T> initialize(List<T> plugins) {
Assert.notNull(plugins); Assert.notNull(plugins, "Plugins must not be null!");
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<T>();
for (T plugin : this.plugins) { for (T plugin : this.plugins) {

View File

@@ -38,8 +38,8 @@ import org.springframework.util.Assert;
* *
* @author Oliver Gierke * @author Oliver Gierke
*/ */
public abstract class AbstractTypeAwareSupport<T> implements ApplicationContextAware, public abstract class AbstractTypeAwareSupport<T>
ApplicationListener<ContextRefreshedEvent>, InitializingBean { implements ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>, InitializingBean {
private ApplicationContext context; private ApplicationContext context;
private Class<T> type; private Class<T> type;
@@ -132,8 +132,8 @@ public abstract class AbstractTypeAwareSupport<T> implements ApplicationContextA
public BeansOfTypeTargetSource(ListableBeanFactory context, Class<?> type, boolean eagerInit, public BeansOfTypeTargetSource(ListableBeanFactory context, Class<?> type, boolean eagerInit,
Collection<Class<?>> exclusions) { Collection<Class<?>> exclusions) {
Assert.notNull(context); Assert.notNull(context, "ListableBeanFactory must not be null!");
Assert.notNull(type); Assert.notNull(type, "Type must not be null!");
this.context = context; this.context = context;
this.type = type; this.type = type;

View File

@@ -39,8 +39,7 @@ public class BeanListFactoryBeanUnitTest {
BeanListFactoryBean<Ordered> factory; BeanListFactoryBean<Ordered> factory;
@Mock @Mock ApplicationContext context;
ApplicationContext context;
@Before @Before
public void setUp() { public void setUp() {
@@ -52,6 +51,7 @@ public class BeanListFactoryBeanUnitTest {
} }
@Test @Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void regardsOrderOfBeans() throws Exception { public void regardsOrderOfBeans() throws Exception {
// They shall be switched in the result. // They shall be switched in the result.

42
pom.xml
View File

@@ -12,7 +12,7 @@
<name>Pivotal Software, Inc.</name> <name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url> <url>http://www.spring.io</url>
</organization> </organization>
<inceptionYear>2008-2016</inceptionYear> <inceptionYear>2008-2017</inceptionYear>
<url>https://github.com/spring-projects/spring-plugin</url> <url>https://github.com/spring-projects/spring-plugin</url>
<licenses> <licenses>
@@ -44,8 +44,8 @@
</modules> </modules>
<properties> <properties>
<spring.version>4.3.3.BUILD-SNAPSHOT</spring.version> <spring.version>4.3.6.RELEASE</spring.version>
<slf4j.version>1.7.21</slf4j.version> <slf4j.version>1.7.22</slf4j.version>
</properties> </properties>
<developers> <developers>
@@ -62,6 +62,36 @@
</developer> </developer>
</developers> </developers>
<profiles>
<profile>
<id>spring5</id>
<properties>
<spring.version>5.0.0.M3</spring.version>
</properties>
<repositories>
<repository>
<id>spring-libs-milestone</id>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>spring5-next</id>
<properties>
<spring.version>5.0.0.BUILD-SNAPSHOT</spring.version>
</properties>
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>https://repo.spring.io/libs-snapshot</url>
</repository>
</repositories>
</profile>
</profiles>
<dependencies> <dependencies>
<!-- Common test dependencies --> <!-- Common test dependencies -->
@@ -197,10 +227,10 @@
<repositories> <repositories>
<repository> <repository>
<id>spring-libs-snapshot</id> <id>spring-libs-release</id>
<url>https://repo.spring.io/libs-snapshot</url> <url>https://repo.spring.io/libs-release</url>
<snapshots> <snapshots>
<enabled>true</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
</repository> </repository>
</repositories> </repositories>