poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1198693 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
Date Mon, 07 Nov 2011 10:25:35 GMT
Author: yegor
Date: Mon Nov  7 10:25:35 2011
New Revision: 1198693

URL: http://svn.apache.org/viewvc?rev=1198693&view=rev
Log:
Bugzilla 52062: ensure that temporary files in SXSSF are deleted 

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1198693&r1=1198692&r2=1198693&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Nov  7 10:25:35 2011
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta5" date="2011-??-??">
+           <action dev="poi-developers" type="fix">52062 - ensure that temporary files
in SXSSF are deleted</action>
            <action dev="poi-developers" type="fix">50936 - Exception parsing MS Word
8.0 file (as duplicate of 47958)</action>
            <action dev="poi-developers" type="fix">47958 - ArrayIndexOutOfBoundsException
from PicturesTable.getAllPictures() during Escher tree walk</action>
            <action dev="poi-developers" type="fix">51944 - PAPFormattedDiskPage.getPAPX
- IndexOutOfBounds</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1198693&r1=1198692&r2=1198693&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFSheet.java Mon Nov  7 10:25:35
2011
@@ -1284,7 +1284,7 @@ public class SXSSFSheet implements Sheet
 
         public SheetDataWriter() throws IOException 
         {
-            _fd = File.createTempFile("poi-sxxsf-sheet", ".xml");
+            _fd = File.createTempFile("poi-sxssf-sheet", ".xml");
             _fd.deleteOnExit();
             _out = new BufferedWriter(new FileWriter(_fd));
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java?rev=1198693&r1=1198692&r2=1198693&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java Mon Nov  7 10:25:35
2011
@@ -186,30 +186,48 @@ public class SXSSFWorkbook implements Wo
     private void injectData(File zipfile, OutputStream out) throws IOException 
     {
         ZipFile zip = new ZipFile(zipfile);
-
-        ZipOutputStream zos = new ZipOutputStream(out);
-
-        @SuppressWarnings("unchecked")
-        Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
-        while (en.hasMoreElements()) 
+        try
         {
-            ZipEntry ze = en.nextElement();
-            zos.putNextEntry(new ZipEntry(ze.getName()));
-            InputStream is = zip.getInputStream(ze);
-            XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName());
-            if(xSheet!=null)
+            ZipOutputStream zos = new ZipOutputStream(out);
+            try
             {
-                SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
-                copyStreamAndInjectWorksheet(is,zos,sxSheet.getWorksheetXMLInputStream());
+                @SuppressWarnings("unchecked")
+                Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
+                while (en.hasMoreElements()) 
+                {
+                    ZipEntry ze = en.nextElement();
+                    zos.putNextEntry(new ZipEntry(ze.getName()));
+                    InputStream is = zip.getInputStream(ze);
+                    XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName());
+                    if(xSheet!=null)
+                    {
+                        SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
+                        InputStream xis = sxSheet.getWorksheetXMLInputStream();
+                        try
+                        {
+                            copyStreamAndInjectWorksheet(is,zos,xis);
+                        }
+                        finally
+                        {
+                            xis.close();
+                        }
+                    }
+                    else
+                    {
+                        copyStream(is, zos);
+                    }
+                    is.close();
+                }
             }
-            else
+            finally
             {
-                copyStream(is, zos);
+                zos.close();
             }
-            is.close();
         }
-
-        zos.close();
+        finally
+        {
+            zip.close();
+        }
     }
     private static void copyStream(InputStream in, OutputStream out) throws IOException {
         byte[] chunk = new byte[1024];
@@ -649,7 +667,7 @@ public class SXSSFWorkbook implements Wo
     	}
     	
         //Save the template
-        File tmplFile = File.createTempFile("poi-sxxsf-template", ".xlsx");
+        File tmplFile = File.createTempFile("poi-sxssf-template", ".xlsx");
         tmplFile.deleteOnExit();
         FileOutputStream os = new FileOutputStream(tmplFile);
         _wb.write(os);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message