From: Dominik Stadler Date: Mon, 25 Sep 2017 15:10:40 +0000 (+0000) Subject: Fix some Sonar issues X-Git-Tag: REL_4_0_0_FINAL~467 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8f324b99fac1733933645289a08b159f63ae5e94;p=poi.git Fix some Sonar issues git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1809636 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java index a005f16781..439b16ce85 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java @@ -94,15 +94,15 @@ public class BigGridDemo { String sheetRef = sheet.getPackagePart().getPartName().getName(); //save the template - FileOutputStream os = new FileOutputStream("template.xlsx"); - wb.write(os); - os.close(); + try (FileOutputStream os = new FileOutputStream("template.xlsx")) { + wb.write(os); + } //Step 2. Generate XML file. File tmp = File.createTempFile("sheet", ".xml"); - Writer fw = new OutputStreamWriter(new FileOutputStream(tmp), XML_ENCODING); - generate(fw, styles); - fw.close(); + try (Writer fw = new OutputStreamWriter(new FileOutputStream(tmp), XML_ENCODING)) { + generate(fw, styles); + } //Step 3. Substitute the template entry with the generated data try (FileOutputStream out = new FileOutputStream("big-grid.xlsx")) { diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java index 931ddcce5f..29b0bddab4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java @@ -140,8 +140,8 @@ public class SXSSFWorkbook implements Workbook { *