mirror of https://github.com/apache/poi.git
fix some Eclipse warnings, unnecessary null-check and missing close() in tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1594201 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa3a7ef63d
commit
8a1411bda1
|
@ -70,7 +70,8 @@ public class ExtractorFactory {
|
||||||
|
|
||||||
/** Should this thread prefer event based over usermodel based extractors? */
|
/** Should this thread prefer event based over usermodel based extractors? */
|
||||||
private static final ThreadLocal<Boolean> threadPreferEventExtractors = new ThreadLocal<Boolean>() {
|
private static final ThreadLocal<Boolean> threadPreferEventExtractors = new ThreadLocal<Boolean>() {
|
||||||
protected Boolean initialValue() { return Boolean.FALSE; }
|
@Override
|
||||||
|
protected Boolean initialValue() { return Boolean.FALSE; }
|
||||||
};
|
};
|
||||||
/** Should all threads prefer event based over usermodel based extractors? */
|
/** Should all threads prefer event based over usermodel based extractors? */
|
||||||
private static Boolean allPreferEventExtractors;
|
private static Boolean allPreferEventExtractors;
|
||||||
|
@ -168,9 +169,9 @@ public class ExtractorFactory {
|
||||||
if(corePart.getContentType().equals(rel.getContentType())) {
|
if(corePart.getContentType().equals(rel.getContentType())) {
|
||||||
if(getPreferEventExtractor()) {
|
if(getPreferEventExtractor()) {
|
||||||
return new XSSFEventBasedExcelExtractor(pkg);
|
return new XSSFEventBasedExcelExtractor(pkg);
|
||||||
} else {
|
|
||||||
return new XSSFExcelExtractor(pkg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new XSSFExcelExtractor(pkg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,10 +318,7 @@ public class ExtractorFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the extractors
|
// Create the extractors
|
||||||
if(
|
if(dirs.size() == 0 && nonPOIFS.size() == 0){
|
||||||
(dirs == null || dirs.size() == 0) &&
|
|
||||||
(nonPOIFS == null || nonPOIFS.size() == 0)
|
|
||||||
){
|
|
||||||
return new POITextExtractor[0];
|
return new POITextExtractor[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -636,19 +636,24 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
||||||
@Test
|
@Test
|
||||||
public void writeWorkbookFromNPOIFS() throws IOException {
|
public void writeWorkbookFromNPOIFS() throws IOException {
|
||||||
InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls");
|
InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls");
|
||||||
NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
|
try {
|
||||||
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
|
||||||
|
try {
|
||||||
|
// Start as NPOIFS
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
|
||||||
|
assertEquals(3, wb.getNumberOfSheets());
|
||||||
|
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
||||||
|
|
||||||
// Start as NPOIFS
|
// Will switch to POIFS
|
||||||
HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
|
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
assertEquals(3, wb.getNumberOfSheets());
|
assertEquals(3, wb.getNumberOfSheets());
|
||||||
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
||||||
|
} finally {
|
||||||
// Will switch to POIFS
|
fs.close();
|
||||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
}
|
||||||
assertEquals(3, wb.getNumberOfSheets());
|
} finally {
|
||||||
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
is.close();
|
||||||
|
}
|
||||||
fs.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue