RESOLVED - BATCH-1569: MultiResourceItemReader.getCurrentResource cause java.lang.ArrayIndexOutOfBoundsException when .read() was not called
This commit is contained in:
@@ -95,9 +95,7 @@ public class MultiResourceItemReader<T> implements ItemReader<T>, ItemStream {
|
||||
delegate.open(new ExecutionContext());
|
||||
}
|
||||
|
||||
T item;
|
||||
item = readNextItem();
|
||||
return item;
|
||||
return readNextItem();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +207,7 @@ public class MultiResourceItemReader<T> implements ItemReader<T>, ItemStream {
|
||||
}
|
||||
|
||||
public Resource getCurrentResource() {
|
||||
if (currentResource >= resources.length) {
|
||||
if (currentResource >= resources.length || currentResource < 0) {
|
||||
return null;
|
||||
}
|
||||
return resources[currentResource];
|
||||
|
||||
@@ -344,5 +344,12 @@ public class MultiResourceItemReaderIntegrationTests {
|
||||
//the 1st item, rather than on open
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCurrentResourceBeforeRead() throws Exception {
|
||||
tested.open(ctx);
|
||||
assertNull("There is no 'current' resource before read is called", tested.getCurrentResource());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user