fix questionable List.remove(int) in SXSSFITestDataProvider
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1725042 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
94fdd517aa
commit
18c5045d5b
@ -24,7 +24,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.apache.poi.POIDataSamples;
|
import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.ss.ITestDataProvider;
|
import org.apache.poi.ss.ITestDataProvider;
|
||||||
@ -43,7 +43,7 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
|
|||||||
|
|
||||||
// an instance of all SXSSFWorkbooks opened by this TestDataProvider,
|
// an instance of all SXSSFWorkbooks opened by this TestDataProvider,
|
||||||
// so that the temporary files created can be disposed up by cleanup()
|
// so that the temporary files created can be disposed up by cleanup()
|
||||||
private final List<SXSSFWorkbook> instances = new ArrayList<SXSSFWorkbook>();
|
private final Collection<SXSSFWorkbook> instances = new ArrayList<SXSSFWorkbook>();
|
||||||
|
|
||||||
private SXSSFITestDataProvider() {
|
private SXSSFITestDataProvider() {
|
||||||
// enforce singleton
|
// enforce singleton
|
||||||
@ -107,11 +107,10 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
|
|||||||
|
|
||||||
public synchronized boolean cleanup(){
|
public synchronized boolean cleanup(){
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
for(int i = 0; i < instances.size(); i++){
|
for(final SXSSFWorkbook wb : instances) {
|
||||||
SXSSFWorkbook wb = instances.get(i);
|
|
||||||
ok = ok && wb.dispose();
|
ok = ok && wb.dispose();
|
||||||
instances.remove(i);
|
|
||||||
}
|
}
|
||||||
|
instances.clear();
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user