poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1845629 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
Date Fri, 02 Nov 2018 22:59:58 GMT
Author: kiwiwings
Date: Fri Nov  2 22:59:58 2018
New Revision: 1845629

URL: http://svn.apache.org/viewvc?rev=1845629&view=rev
Log:
Bug 62872 - Writing large files with 800k rows gives java.io.IOException: This archive contains
unclosed entries.

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java

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=1845629&r1=1845628&r2=1845629&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 Fri Nov  2 22:59:58
2018
@@ -381,7 +381,10 @@ public class SXSSFWorkbook implements Wo
             Enumeration<? extends ZipArchiveEntry> en = zipEntrySource.getEntries();
             while (en.hasMoreElements()) {
                 ZipArchiveEntry ze = en.nextElement();
-                zos.putArchiveEntry(new ZipArchiveEntry(ze.getName()));
+                ZipArchiveEntry zeOut = new ZipArchiveEntry(ze.getName());
+                zeOut.setSize(ze.getSize());
+                zeOut.setTime(ze.getTime());
+                zos.putArchiveEntry(zeOut);
                 try (final InputStream is = zipEntrySource.getInputStream(ze)) {
                     if (is instanceof ZipArchiveThresholdInputStream) {
                         // #59743 - disable Threshold handling for SXSSF copy

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java?rev=1845629&r1=1845628&r2=1845629&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java Fri Nov
 2 22:59:58 2018
@@ -21,7 +21,10 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.Date;
 
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
@@ -34,6 +37,9 @@ import org.apache.poi.ss.usermodel.Workb
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.SXSSFITestDataProvider;
 import org.apache.poi.xssf.XSSFITestDataProvider;
+import org.apache.poi.xssf.streaming.SXSSFCell;
+import org.apache.poi.xssf.streaming.SXSSFRow;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -166,4 +172,45 @@ public final class TestSXSSFBugs extends
         CellRangeAddress range = new CellRangeAddress(rowIndex, rowIndex, colIndex, colIndex);
         sheet.setArrayFormula(col1Value, range);
     }
+
+    @Test
+    @Ignore("takes too long for the normal test run")
+    public void test62872() throws Exception {
+        final int COLUMN_COUNT = 300;
+        final int ROW_COUNT = 600000;
+        final int TEN_MINUTES = 1000*60*10;
+
+        SXSSFWorkbook workbook = new SXSSFWorkbook(100);
+        workbook.setCompressTempFiles(true);
+        SXSSFSheet sheet = workbook.createSheet("RawData");
+
+        SXSSFRow row = sheet.createRow(0);
+        SXSSFCell cell;
+
+        for (int i = 1; i <= COLUMN_COUNT; i++) {
+            cell = row.createCell(i - 1);
+            cell.setCellValue("Column " + i);
+        }
+
+        for (int i = 1; i < ROW_COUNT; i++) {
+            row = sheet.createRow(i);
+            for (int j = 1; j <= COLUMN_COUNT; j++) {
+                cell = row.createCell(j - 1);
+
+                //make some noise
+                cell.setCellValue(new Date(i*TEN_MINUTES+(j*TEN_MINUTES)/COLUMN_COUNT));
+            }
+            i++;
+            // if (i % 1000 == 0)
+            // logger.info("Created Row " + i);
+        }
+
+        try (FileOutputStream out = new FileOutputStream(File.createTempFile("test62872",
".xlsx"))) {
+            workbook.write(out);
+            workbook.dispose();
+            workbook.close();
+            out.flush();
+        }
+        // logger.info("File written!");
+    }
 }



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


Mime
View raw message