Throw IllegalStateException from afterPropertiesSet
Consistently use Assert.state in the afterPropertiesSet() methods to throw IllegalStateException instead of IllegalArgumentException when some properties are missing and/or invalid. Resolves #2244
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
b9d6e26d61
commit
fc0ec01ff8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2012 the original author or authors.
|
||||
* Copyright 2006-2022 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.
|
||||
@@ -39,7 +39,7 @@ public class StagingItemListener extends StepListenerSupport<Long, Long> impleme
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate, "You must provide a DataSource.");
|
||||
Assert.state(jdbcTemplate != null, "You must provide a DataSource.");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009-2019 the original author or authors.
|
||||
* Copyright 2009-2022 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.
|
||||
@@ -49,7 +49,7 @@ public class StagingItemProcessor<T> implements ItemProcessor<ProcessIndicatorIt
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate, "Either jdbcTemplate or dataSource must be set");
|
||||
Assert.state(jdbcTemplate != null, "Either jdbcTemplate or dataSource must be set");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 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.
|
||||
@@ -72,7 +72,7 @@ public class StagingItemReader<T>
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate, "You must provide a DataSource.");
|
||||
Assert.state(jdbcTemplate != null, "You must provide a DataSource.");
|
||||
}
|
||||
|
||||
private List<Long> retrieveKeys() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 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.
|
||||
@@ -68,7 +68,7 @@ public class AggregateItemFieldSetMapper<T> implements FieldSetMapper<AggregateI
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(delegate, "A FieldSetMapper delegate must be provided.");
|
||||
Assert.state(delegate != null, "A FieldSetMapper delegate must be provided.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ public class HibernateAwareCustomerCreditItemWriter implements ItemWriter<Custom
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.state(sessionFactory != null, "Hibernate SessionFactory is required");
|
||||
Assert.notNull(dao, "Delegate DAO must be set");
|
||||
Assert.state(dao != null, "Delegate DAO must be set");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 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.
|
||||
@@ -47,7 +47,7 @@ public class GeneratingTradeResettingListener implements StepExecutionListener,
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(this.reader, "The 'reader' must be set.");
|
||||
Assert.state(this.reader != null, "The 'reader' must be set.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class AggregateItemFieldSetMapperTests {
|
||||
|
||||
@Test
|
||||
void testMandatoryProperties() {
|
||||
assertThrows(IllegalArgumentException.class, mapper::afterPropertiesSet);
|
||||
assertThrows(IllegalStateException.class, mapper::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user