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

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

commit f1de5a8d87217f70b1f71af75ea57213a51036a9
Author: Dominik Stadler <[email protected]>
AuthorDate: Sun Oct 25 08:59:03 2026 +0100

    Avoid duplicate work in XSSFBFileHandler
    
    handleFile() and handleExtracting() are both called for each
    file during integration-testing, so they should not both
    perform the same actions.
---
 .../org/apache/poi/stress/XSSFBFileHandler.java    | 32 +++++-----------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git 
a/poi-integration/src/test/java/org/apache/poi/stress/XSSFBFileHandler.java 
b/poi-integration/src/test/java/org/apache/poi/stress/XSSFBFileHandler.java
index 190ec6ea3a..806d098797 100644
--- a/poi-integration/src/test/java/org/apache/poi/stress/XSSFBFileHandler.java
+++ b/poi-integration/src/test/java/org/apache/poi/stress/XSSFBFileHandler.java
@@ -42,37 +42,19 @@ public class XSSFBFileHandler extends AbstractFileHandler {
         byte[] bytes = IOUtils.toByteArray(stream);
 
         try (OPCPackage opcPackage = 
OPCPackage.open(UnsynchronizedByteArrayInputStream.builder().setByteArray(bytes).get()))
 {
-            testOne(opcPackage);
-        }
-
-        try (OPCPackage opcPackage = 
OPCPackage.open(UnsynchronizedByteArrayInputStream.builder().setByteArray(bytes).get()))
 {
-            testNotHandledByWorkbookException(opcPackage);
-        }
-    }
-
-    private void testNotHandledByWorkbookException(OPCPackage pkg) throws 
IOException {
-        try {
-            new XSSFWorkbook(pkg).close();
-        } catch (XLSBUnsupportedException e) {
-            //this is what we'd expect
-            //swallow
+            try {
+                new XSSFWorkbook(opcPackage).close();
+            } catch (XLSBUnsupportedException e) {
+                //this is what we'd expect
+                //swallow
+            }
         }
     }
 
     @Override
     public void handleExtracting(File file) throws Exception {
-        OPCPackage pkg = OPCPackage.open(file, PackageAccess.READ);
-        try {
+        try (OPCPackage pkg = OPCPackage.open(file, PackageAccess.READ)) {
             testOne(pkg);
-        } finally {
-            pkg.close();
-        }
-
-        pkg = OPCPackage.open(file, PackageAccess.READ);
-        try {
-            testNotHandledByWorkbookException(pkg);
-        } finally {
-            pkg.close();
         }
     }
 


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

Reply via email to