diff options
author | Dominik Stadler <centic@apache.org> | 2019-01-11 19:31:05 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2019-01-11 19:31:05 +0000 |
commit | 32c43c068cbaaa6ed5fa25f701f7cc61c61d7d41 (patch) | |
tree | 86ec615a563294a6163b0f43eb23c72bfa9b3b2b | |
parent | a1a179729905b237dbdbfa96337357965d766fab (diff) | |
download | poi-32c43c068cbaaa6ed5fa25f701f7cc61c61d7d41.tar.gz poi-32c43c068cbaaa6ed5fa25f701f7cc61c61d7d41.zip |
IDE and JavaDoc fixes, move/remove some unfixed tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1851089 13f79535-47bb-0310-9956-ffa450edef68
18 files changed, 82 insertions, 169 deletions
diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/TestAllFiles.java index 33bd696195..6daf088ac3 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/TestAllFiles.java @@ -474,15 +474,15 @@ public class TestAllFiles { public static class NullFileHandler implements FileHandler { @Override - public void handleFile(InputStream stream, String path) throws Exception { + public void handleFile(InputStream stream, String path) { } @Override - public void handleExtracting(File file) throws Exception { + public void handleExtracting(File file) { } @Override - public void handleAdditional(File file) throws Exception { + public void handleAdditional(File file) { } } } diff --git a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java index 954163cb60..a2a601ea1f 100644 --- a/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java +++ b/src/java/org/apache/poi/ddf/DefaultEscherRecordFactory.java @@ -117,11 +117,7 @@ public class DefaultEscherRecordFactory implements EscherRecordFactory { short sid; try { sid = recCls.getField("RECORD_ID").getShort(null); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (NoSuchFieldException e) { + } catch (IllegalArgumentException | NoSuchFieldException | IllegalAccessException e) { throw new RuntimeException(e); } Constructor<? extends EscherRecord> constructor; diff --git a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java index 28ee51f32b..55c32fb4f5 100644 --- a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java @@ -276,7 +276,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p @Override public String getText() { - StringBuffer text = new StringBuffer(); + StringBuilder text = new StringBuilder(); // We don't care about the difference between // null (missing) and blank cells @@ -374,7 +374,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p // Replace any newlines with spaces, otherwise it // breaks the output String commentText = comment.getString().getString().replace('\n', ' '); - text.append(" Comment by "+comment.getAuthor()+": "+commentText); + text.append(" Comment by ").append(comment.getAuthor()).append(": ").append(commentText); } } @@ -398,7 +398,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p } public static String _extractHeaderFooter(HeaderFooter hf) { - StringBuffer text = new StringBuffer(); + StringBuilder text = new StringBuilder(); if(hf.getLeft() != null) { text.append(hf.getLeft()); diff --git a/src/java/org/apache/poi/hssf/record/RecordFactory.java b/src/java/org/apache/poi/hssf/record/RecordFactory.java index 8b5c0224c1..4bc14d68d3 100644 --- a/src/java/org/apache/poi/hssf/record/RecordFactory.java +++ b/src/java/org/apache/poi/hssf/record/RecordFactory.java @@ -82,11 +82,7 @@ public final class RecordFactory { Object[] args = { in, }; try { return _c.newInstance(args); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException | InstantiationException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); @@ -118,9 +114,7 @@ public final class RecordFactory { Object[] args = { in, }; try { return (Record) _m.invoke(null, args); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } catch (IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new org.apache.poi.util.RecordFormatException("Unable to construct record instance" , e.getTargetException()); diff --git a/src/java/org/apache/poi/hssf/record/SupBookRecord.java b/src/java/org/apache/poi/hssf/record/SupBookRecord.java index bda7cca026..32046669a6 100644 --- a/src/java/org/apache/poi/hssf/record/SupBookRecord.java +++ b/src/java/org/apache/poi/hssf/record/SupBookRecord.java @@ -135,7 +135,7 @@ public final class SupBookRecord extends StandardRecord { if(isExternalReferences()) { sb.append("External References]\n"); - sb.append(" .url = ").append(field_2_encoded_url).append("\n"); + sb.append(" .url = ").append(getURL()).append("\n"); sb.append(" .nSheets = ").append(field_1_number_of_sheets).append("\n"); for (String sheetname : field_3_sheet_names) { sb.append(" .name = ").append(sheetname).append("\n"); diff --git a/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java b/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java index ff12e1df8c..03de03ebbd 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/SharedValueManager.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.record.aggregates; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,11 +93,9 @@ public final class SharedValueManager { } public final String toString() { - StringBuffer sb = new StringBuffer(64); - sb.append(getClass().getName()).append(" ["); - sb.append(_sfr.getRange()); - sb.append("]"); - return sb.toString(); + return getClass().getName() + " [" + + _sfr.getRange() + + "]"; } } @@ -135,9 +134,7 @@ public final class SharedValueManager { */ private static <Z> List<Z> toList(Z[] zz) { List<Z> result = new ArrayList<>(zz.length); - for (int i = 0; i < zz.length; i++) { - result.add(zz[i]); - } + Collections.addAll(result, zz); return result; } diff --git a/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java b/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java index feea7d7b45..dc6a8c0255 100644 --- a/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java +++ b/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java @@ -21,7 +21,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashSet; @@ -146,9 +145,8 @@ final class FunctionMetadataReader { private static boolean isDash(String codes) { if(codes.length() == 1) { - switch (codes.charAt(0)) { - case '-': - return true; + if (codes.charAt(0) == '-') { + return true; } } return false; diff --git a/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java b/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java index 8888687157..28b5e7d9e5 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java +++ b/src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java @@ -59,12 +59,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg { } public final String toString() { - StringBuilder sb = new StringBuilder(64); - sb.append(getClass().getName()).append(" ["); - sb.append(lookupName(_functionIndex)); - sb.append(" nArgs=").append(_numberOfArgs); - sb.append("]"); - return sb.toString(); + return getClass().getName() + " [" + lookupName(_functionIndex) + " nArgs=" + _numberOfArgs + "]"; } public final short getFunctionIndex() { diff --git a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java index 4267898309..e1a7b2e9d3 100644 --- a/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java +++ b/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java @@ -799,8 +799,7 @@ public abstract class XDDFChart extends POIXMLDocumentPart implements TextContai XSSFSheet sheet = null; try { sheet = getWorkbook().getSheetAt(0); - } catch (InvalidFormatException ife) { - } catch (IOException ioe) { + } catch (InvalidFormatException | IOException ife) { } return sheet; } diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java index b3283ff110..8b9d152848 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGraphicFrame.java @@ -192,9 +192,7 @@ public class XSLFGraphicFrame extends XSLFShape implements GraphicalFrame<XSLFSh chartCopy.importContent(srcChart); chartCopy.setWorkbook(srcChart.getWorkbook()); c.setAttributeText(idQualifiedName, slide.getRelationId(chartCopy)); - } catch (InvalidFormatException e) { - throw new POIXMLException(e); - } catch (IOException e) { + } catch (InvalidFormatException | IOException e) { throw new POIXMLException(e); } c.dispose(); diff --git a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java index 819547ad28..8d1ce1a949 100644 --- a/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java +++ b/src/ooxml/java/org/apache/poi/xssf/eventusermodel/XSSFReader.java @@ -254,9 +254,7 @@ public class XSSFReader { XMLReader xmlReader; try { xmlReader = SAXHelper.newXMLReader(); - } catch (ParserConfigurationException e) { - throw new POIXMLException(e); - } catch (SAXException e) { + } catch (ParserConfigurationException | SAXException e) { throw new POIXMLException(e); } xmlReader.setContentHandler(xmlSheetRefReader); diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index 65e6d00dd1..04b4bea38f 100644 --- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -1184,9 +1184,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { docPr.setName("chart " + id); return inline; - } catch (XmlException e) { - throw new IllegalStateException(e); - } catch (SAXException e) { + } catch (XmlException | SAXException e) { throw new IllegalStateException(e); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java index 45b130578a..eb392080c2 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java @@ -57,45 +57,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow; */ public final class TestUnfixedBugs { @Test - public void testBug54084Unicode() throws IOException { - // sample XLSX with the same text-contents as the text-file above - XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("54084 - Greek - beyond BMP.xlsx"); - - verifyBug54084Unicode(wb); - - //XSSFTestDataSamples.writeOut(wb, "bug 54084 for manual review"); - - // now write the file and read it back in - XSSFWorkbook wbWritten = XSSFTestDataSamples.writeOutAndReadBack(wb); - verifyBug54084Unicode(wbWritten); - - // finally also write it out via the streaming interface and verify that we still can read it back in - SXSSFWorkbook swb = new SXSSFWorkbook(wb); - Workbook wbStreamingWritten = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb); - verifyBug54084Unicode(wbStreamingWritten); - - wbWritten.close(); - swb.close(); - wbStreamingWritten.close(); - wb.close(); - } - - private void verifyBug54084Unicode(Workbook wb) { - // expected data is stored in UTF-8 in a text-file - byte[] data = HSSFTestDataSamples.getTestDataFileContent("54084 - Greek - beyond BMP.txt"); - String testData = new String(data, StandardCharsets.UTF_8).trim(); - - Sheet sheet = wb.getSheetAt(0); - Row row = sheet.getRow(0); - Cell cell = row.getCell(0); - - String value = cell.getStringCellValue(); - //System.out.println(value); - - assertEquals("The data in the text-file should exactly match the data that we read from the workbook", testData, value); - } - - @Test public void test54071() throws Exception { Workbook workbook = XSSFTestDataSamples.openSampleWorkbook("54071.xlsx"); Sheet sheet = workbook.getSheetAt(0); @@ -197,8 +158,7 @@ public final class TestUnfixedBugs { @Test public void testBug55752() throws IOException { - Workbook wb = new XSSFWorkbook(); - try { + try (Workbook wb = new XSSFWorkbook()) { Sheet sheet = wb.createSheet("test"); for (int i = 0; i < 4; i++) { @@ -247,8 +207,6 @@ public final class TestUnfixedBugs { // write to file for manual inspection XSSFTestDataSamples.writeOut(wb, "bug 55752 for review"); - } finally { - wb.close(); } } @@ -315,7 +273,7 @@ public final class TestUnfixedBugs { } // verify that the resulting XML has the rows in correct order as required by Excel - String xml = new String(stream.toByteArray(), "UTF-8"); + String xml = new String(stream.toByteArray(), StandardCharsets.UTF_8); int posR12 = xml.indexOf("<row r=\"12\""); int posR13 = xml.indexOf("<row r=\"13\""); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 9d94f80568..610ac7b22f 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -35,6 +35,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; @@ -116,6 +117,7 @@ import org.apache.poi.ss.util.CellUtil; import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.NullOutputStream; import org.apache.poi.util.TempFile; +import org.apache.poi.xssf.SXSSFITestDataProvider; import org.apache.poi.xssf.XLSBUnsupportedException; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; @@ -3389,4 +3391,44 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { assertEquals("E11", sheet.getActiveCell().formatAsString()); wbBack.close(); } + + @Test + public void testBug54084Unicode() throws IOException { + // sample XLSX with the same text-contents as the text-file above + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("54084 - Greek - beyond BMP.xlsx"); + + verifyBug54084Unicode(wb); + + //XSSFTestDataSamples.writeOut(wb, "bug 54084 for manual review"); + + // now write the file and read it back in + XSSFWorkbook wbWritten = XSSFTestDataSamples.writeOutAndReadBack(wb); + verifyBug54084Unicode(wbWritten); + + // finally also write it out via the streaming interface and verify that we still can read it back in + SXSSFWorkbook swb = new SXSSFWorkbook(wb); + Workbook wbStreamingWritten = SXSSFITestDataProvider.instance.writeOutAndReadBack(swb); + verifyBug54084Unicode(wbStreamingWritten); + + wbWritten.close(); + swb.close(); + wbStreamingWritten.close(); + wb.close(); + } + + private void verifyBug54084Unicode(Workbook wb) { + // expected data is stored in UTF-8 in a text-file + byte[] data = HSSFTestDataSamples.getTestDataFileContent("54084 - Greek - beyond BMP.txt"); + String testData = new String(data, StandardCharsets.UTF_8).trim(); + + Sheet sheet = wb.getSheetAt(0); + Row row = sheet.getRow(0); + Cell cell = row.getCell(0); + + String value = cell.getStringCellValue(); + //System.out.println(value); + + assertEquals("The data in the text-file should exactly match the data that we read from the workbook", testData, value); + } + } diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java index 0bc08772ed..13cce30251 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestBasic.java @@ -123,9 +123,7 @@ public final class TestBasic { Object o; try { o = PropertySetFactory.create(in); - } catch (NoPropertySetStreamException ex) { - o = ex; - } catch (MarkUnsupportedException ex) { + } catch (NoPropertySetStreamException | MarkUnsupportedException ex) { o = ex; } in.close(); diff --git a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java index 92e82d32e0..bdc7c5b6de 100644 --- a/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java +++ b/src/testcases/org/apache/poi/hpsf/basic/TestEmptyProperties.java @@ -113,9 +113,7 @@ public final class TestEmptyProperties { Object o; try { o = PropertySetFactory.create(in); - } catch (NoPropertySetStreamException ex) { - o = ex; - } catch (MarkUnsupportedException ex) { + } catch (NoPropertySetStreamException | MarkUnsupportedException ex) { o = ex; } in.close(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java index c6d4cca288..1fea921da6 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestUnfixedBugs.java @@ -28,11 +28,8 @@ import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.util.RecordFormatException; import org.junit.Test; -import junit.framework.AssertionFailedError; - /** * @author aviks * @@ -43,100 +40,51 @@ import junit.framework.AssertionFailedError; * fixed, so that they are then run automatically. */ public final class TestUnfixedBugs { - - @Test - public void test43493() { - // Has crazy corrupt sub-records on - // a EmbeddedObjectRefSubRecord - try { - HSSFTestDataSamples.openSampleWorkbook("43493.xls"); - } catch (RecordFormatException e) { - if (e.getCause().getCause() instanceof ArrayIndexOutOfBoundsException) { - throw new AssertionFailedError("Identified bug 43493"); - } - throw e; - } - } - - /** - * Note - some parts of this bug have been fixed, and have been - * transfered over to {@link TestBugs#bug49612_part()} - */ - @Test - public void test49612() throws IOException { - HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("49612.xls"); - HSSFSheet sh = wb.getSheetAt(0); - HSSFRow row = sh.getRow(0); - HSSFCell c1 = row.getCell(2); - HSSFCell d1 = row.getCell(3); - HSSFCell e1 = row.getCell(2); - - assertEquals("SUM(BOB+JIM)", c1.getCellFormula()); - - // Problem 1: Filename missing, see bug #56742 - assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", d1.getCellFormula()); - - //Problem 2: Filename missing, see bug #56742 - //junit.framework.ComparisonFailure: - //Expected :SUM('49612.xls'!BOB+'49612.xls'!JIM) - //Actual :SUM(BOB+JIM) - assertEquals("SUM('49612.xls'!BOB+'49612.xls'!JIM)", e1.getCellFormula()); - - // Problem 3 - fixed and transfered - wb.close(); - } - @Test public void testFormulaRecordAggregate_1() throws Exception { // fails at formula "=MEHRFACH.OPERATIONEN(E$3;$B$5;$D4)" - Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958_1.xls"); - try { - for(int i = 0;i < wb.getNumberOfSheets();i++) { + try (Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958_1.xls")) { + for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); assertNotNull(wb.getSheet(sheet.getSheetName())); sheet.groupColumn((short) 4, (short) 5); sheet.setColumnGroupCollapsed(4, true); sheet.setColumnGroupCollapsed(4, false); - - for(Row row : sheet) { - for(Cell cell : row) { + + for (Row row : sheet) { + for (Cell cell : row) { try { - cell.toString(); + assertNotNull(cell.toString()); } catch (Exception e) { throw new Exception("While handling: " + sheet.getSheetName() + "/" + row.getRowNum() + "/" + cell.getColumnIndex(), e); } } } } - } finally { - wb.close(); } } @Test public void testFormulaRecordAggregate() throws Exception { // fails at formula "=MEHRFACH.OPERATIONEN(E$3;$B$5;$D4)" - Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958.xls"); - try { - for(int i = 0;i < wb.getNumberOfSheets();i++) { + try (Workbook wb = HSSFTestDataSamples.openSampleWorkbook("44958.xls")) { + for (int i = 0; i < wb.getNumberOfSheets(); i++) { Sheet sheet = wb.getSheetAt(i); assertNotNull(wb.getSheet(sheet.getSheetName())); sheet.groupColumn((short) 4, (short) 5); sheet.setColumnGroupCollapsed(4, true); sheet.setColumnGroupCollapsed(4, false); - - for(Row row : sheet) { - for(Cell cell : row) { + + for (Row row : sheet) { + for (Cell cell : row) { try { - cell.toString(); + assertNotNull(cell.toString()); } catch (Exception e) { throw new Exception("While handling: " + sheet.getSheetName() + "/" + row.getRowNum() + "/" + cell.getColumnIndex(), e); } } } - } - } finally { - wb.close(); + } } } diff --git a/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java b/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java index 173ccb7d9c..fe868dbdd9 100644 --- a/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java +++ b/src/testcases/org/apache/poi/ss/formula/function/ExcelFileFormatDocFunctionExtractor.java @@ -449,9 +449,7 @@ public final class ExcelFileFormatDocFunctionExtractor { try { xr.parse(inSrc); is.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (SAXException e) { + } catch (IOException | SAXException e) { throw new RuntimeException(e); } } @@ -521,8 +519,6 @@ public final class ExcelFileFormatDocFunctionExtractor { InputStream is = zf.getInputStream(zf.getEntry("content.xml")); extractFunctionData(new FunctionDataCollector(ps), is); zf.close(); - } catch (ZipException e) { - throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } |