diff options
author | Dominik Stadler <centic@apache.org> | 2019-12-15 14:53:11 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2019-12-15 14:53:11 +0000 |
commit | 1a5cec89d8d36f2a7cd5643b221befd57fa515b7 (patch) | |
tree | 6a6719f33761c08a719599393ca310eafcb7834e /src/testcases/org/apache/poi/ss/formula | |
parent | 2748844549b50dc11e8ef19dcd506c820c1a1e19 (diff) | |
download | poi-1a5cec89d8d36f2a7cd5643b221befd57fa515b7.tar.gz poi-1a5cec89d8d36f2a7cd5643b221befd57fa515b7.zip |
Replace manual close with try-with-resources
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871590 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss/formula')
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java | 5 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java | 5 |
2 files changed, 2 insertions, 8 deletions
diff --git a/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java b/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java index be2cc54cde..06c37dc025 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java +++ b/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java @@ -226,8 +226,7 @@ public class TestWorkbookEvaluator { */ @Test public void testResultOutsideRange() throws IOException { - Workbook wb = new HSSFWorkbook(); - try { + try (Workbook wb = new HSSFWorkbook()) { Cell cell = wb.createSheet("Sheet1").createRow(0).createCell(0); cell.setCellFormula("D2:D5"); // IF(TRUE,D2:D5,D2) or OFFSET(D2:D5,0,0) would work too FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator(); @@ -249,8 +248,6 @@ public class TestWorkbookEvaluator { cv = fe.evaluate(cell); assertEquals(CellType.ERROR, cv.getCellType()); assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue()); - } finally { - wb.close(); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java b/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java index 6cc50e742b..462acd3115 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestFixed.java @@ -44,13 +44,10 @@ public final class TestFixed { @Before public void setUp() throws IOException { - HSSFWorkbook wb = new HSSFWorkbook(); - try { + try (HSSFWorkbook wb = new HSSFWorkbook()) { HSSFSheet sheet = wb.createSheet("new sheet"); cell11 = sheet.createRow(0).createCell(0); evaluator = new HSSFFormulaEvaluator(wb); - } finally { - wb.close(); } } |