#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.