StagingItemReader open() can be called multiple times concurrently, so no need to assert that it isn't already open.

This commit is contained in:
dsyer
2007-12-24 14:15:52 +00:00
parent 19164926b6
commit 5eba0085bd

View File

@@ -24,7 +24,6 @@ import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import org.springframework.util.Assert;
public class StagingItemReader extends JdbcDaoSupport implements ItemReader, ResourceLifecycle, DisposableBean,
StepContextAware {
@@ -71,16 +70,15 @@ public class StagingItemReader extends JdbcDaoSupport implements ItemReader, Res
* @see org.springframework.batch.io.driving.DrivingQueryItemReader#open()
*/
public void open() {
Assert.state(keys == null || initialized, "Cannot open an already open StagingItemProvider"
+ ", call close() first.");
// Can be called from multiple threads because of lazy initialisation...
synchronized (lock) {
if (keys == null) {
keys = retrieveKeys().iterator();
logger.info("Keys obtained for staging.");
registerSynchronization();
initialized = true;
}
}
registerSynchronization();
initialized = true;
}
/**