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? */
|
||||
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? */
|
||||
private static Boolean allPreferEventExtractors;
|
||||
|
@ -168,9 +169,9 @@ public class ExtractorFactory {
|
|||
if(corePart.getContentType().equals(rel.getContentType())) {
|
||||
if(getPreferEventExtractor()) {
|
||||
return new XSSFEventBasedExcelExtractor(pkg);
|
||||
} else {
|
||||
return new XSSFExcelExtractor(pkg);
|
||||
}
|
||||
|
||||
return new XSSFExcelExtractor(pkg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,10 +318,7 @@ public class ExtractorFactory {
|
|||
}
|
||||
|
||||
// Create the extractors
|
||||
if(
|
||||
(dirs == null || dirs.size() == 0) &&
|
||||
(nonPOIFS == null || nonPOIFS.size() == 0)
|
||||
){
|
||||
if(dirs.size() == 0 && nonPOIFS.size() == 0){
|
||||
return new POITextExtractor[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -636,19 +636,24 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
|
|||
@Test
|
||||
public void writeWorkbookFromNPOIFS() throws IOException {
|
||||
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
|
||||
HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
||||
|
||||
// Will switch to POIFS
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
||||
|
||||
fs.close();
|
||||
// Will switch to POIFS
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
assertEquals("Root xls", wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue());
|
||||
} finally {
|
||||
fs.close();
|
||||
}
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue