]> source.dussan.org Git - poi.git/commitdiff
remove finalizer
authorPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 18:09:26 +0000 (18:09 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 22 Oct 2021 18:09:26 +0000 (18:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1894490 13f79535-47bb-0310-9956-ffa450edef68

poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/DeferredGeneration.java
poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/Outlining.java
poi-examples/src/main/java/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SheetDataWriter.java

index e5b5eba6f11b4324b9671e8d6df590d4941c1feb..1b98bb26ab11f28a924f8dd488dc020b991119ed 100644 (file)
@@ -56,6 +56,7 @@ public class DeferredGeneration {
                 //writeAvoidingTempFiles was added as an experimental change in POI 5.1.0
                 //wb.writeAvoidingTempFiles(fileOut);
             } finally {
+                //the dispose call is necessary to ensure temp files are removed
                 wb.dispose();
             }
             System.out.println("wrote DeferredGeneration.xlsx");
index 6c29813edd4788b9ac13e30a782f4646c175414b..31b15dcb16656e84918f756c3be169e99525d3f7 100644 (file)
@@ -47,6 +47,7 @@ public class Outlining {
             try (FileOutputStream fileOut = new FileOutputStream("outlining_collapsed.xlsx")) {
                 wb2.write(fileOut);
             } finally {
+                //the dispose call is necessary to ensure temp files are removed
                 wb2.dispose();
             }
         }
index df5b7004cfedf8bc28a972869712254c8de2e402..aabfd5955c77a995fafc785a7ad1d162366c4a62 100644 (file)
@@ -80,6 +80,7 @@ public final class SavePasswordProtectedXlsx {
             }
         } finally {
             wb.close();
+            //the dispose call is necessary to ensure temp files are removed
             wb.dispose();
         }
         TempFileUtils.checkTempFiles();
index b25c5422b8f0a9922bde5feff4dd402ab67f4f14..c339b12eea29958bdf5da798ccd87fbf8a9e6973 100644 (file)
@@ -152,6 +152,9 @@ public class SheetDataWriter implements Closeable {
      */
     public InputStream getWorksheetXMLInputStream() throws IOException {
         File fd = getTempFile();
+        if (fd == null) {
+            throw new IOException("getWorksheetXMLInputStream only works when a temp file is used");
+        }
         FileInputStream fis = new FileInputStream(fd);
         try {
             return decorateInputStream(fis);