#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")
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.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) {
Assert.notNull(plugins);
Assert.notNull(plugins, "Plugins must not be null!");
List<T> result = new ArrayList<T>();
for (T plugin : this.plugins) {

View File

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

View File

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

42
pom.xml
View File

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