This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 65747422b3 Update TestXSSFWorkbook.java
65747422b3 is described below

commit 65747422b36439b1fdb66370fbbfcf96e6991609
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Aug 14 12:10:49 2025 +0100

    Update TestXSSFWorkbook.java
---
 .../poi/xssf/usermodel/TestXSSFWorkbook.java       | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git 
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java 
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
index 4528d56049..10826e97d2 100644
--- 
a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
+++ 
b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
@@ -1311,6 +1311,30 @@ public final class TestXSSFWorkbook extends 
BaseTestXWorkbook {
         }
     }
 
+    @Test
+    void testNewWorkbookWithTempFilePackagePartsClose() throws Exception {
+        try (UnsynchronizedByteArrayOutputStream bos = 
UnsynchronizedByteArrayOutputStream.builder().get()) {
+            ZipPackage.setUseTempFilePackageParts(true);
+            try (XSSFWorkbook workbook = new XSSFWorkbook()) {
+                XSSFSheet sheet = workbook.createSheet("sheet1");
+                XSSFRow row = sheet.createRow(0);
+                XSSFCell cell0 = row.createCell(0);
+                cell0.setCellValue("");
+                XSSFCell cell1 = row.createCell(1);
+                cell1.setCellErrorValue(FormulaError.DIV0);
+                XSSFCell cell2 = row.createCell(2);
+                cell2.setCellErrorValue(FormulaError.FUNCTION_NOT_IMPLEMENTED);
+                workbook.write(bos);
+                // workaround for https://github.com/apache/poi/issues/879
+                for (PackagePart part : workbook.getPackage().getParts()) {
+                    part.close();
+                }
+            } finally {
+                ZipPackage.setUseTempFilePackageParts(false);
+            }
+        }
+    }
+
     @Test
     void testLinkExternalWorkbook() throws Exception {
         String nameA = "link-external-workbook-a.xlsx";


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to