RESOLVED - BATCH-1798: MultiResourceItemReader fails on Restart if

the chunk crashes on the 1st commit.
This commit is contained in:
Robert Kasanicky
2011-10-09 12:43:22 +02:00
parent af4170fe04
commit 6832201363
2 changed files with 99 additions and 70 deletions

View File

@@ -155,7 +155,8 @@ public class MultiResourceItemReader<T> implements ItemReader<T>, ItemStream {
noInput = false;
if (resources.length == 0) {
if (strict) {
throw new IllegalStateException("No resources to read. Set strict=false if this is not an error condition.");
throw new IllegalStateException(
"No resources to read. Set strict=false if this is not an error condition.");
}
else {
logger.warn("No resources to read. Set strict=true if this should be an error condition.");
@@ -168,6 +169,12 @@ public class MultiResourceItemReader<T> implements ItemReader<T>, ItemStream {
if (executionContext.containsKey(executionContextUserSupport.getKey(RESOURCE_KEY))) {
currentResource = executionContext.getInt(executionContextUserSupport.getKey(RESOURCE_KEY));
// context could have been saved before reading anything
if (currentResource == -1) {
currentResource = 0;
}
delegate.setResource(resources[currentResource]);
delegate.open(executionContext);
}