poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1833096 - /poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
Date Thu, 07 Jun 2018 06:03:35 GMT
Author: fanningpj
Date: Thu Jun  7 06:03:35 2018
New Revision: 1833096

URL: http://svn.apache.org/viewvc?rev=1833096&view=rev
Log:
use try with resources

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java?rev=1833096&r1=1833095&r2=1833096&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java Thu Jun  7 06:03:35
2018
@@ -83,24 +83,24 @@ public class VBAMacroReader implements C
     }
     
     private void openOOXML(InputStream zipFile) throws IOException {
-        ZipInputStream zis = new ZipInputStream(zipFile);
-        ZipEntry zipEntry;
-        while ((zipEntry = zis.getNextEntry()) != null) {
-            if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
-                try {
-                    // Make a NPOIFS from the contents, and close the stream
-                    this.fs = new NPOIFSFileSystem(zis);
-                    return;
-                } catch (IOException e) {
-                    // Tidy up
-                    zis.close();
-                    
-                    // Pass on
-                    throw e;
+        try(ZipInputStream zis = new ZipInputStream(zipFile)) {
+            ZipEntry zipEntry;
+            while ((zipEntry = zis.getNextEntry()) != null) {
+                if (endsWithIgnoreCase(zipEntry.getName(), VBA_PROJECT_OOXML)) {
+                    try {
+                        // Make a NPOIFS from the contents, and close the stream
+                        this.fs = new NPOIFSFileSystem(zis);
+                        return;
+                    } catch (IOException e) {
+                        // Tidy up
+                        zis.close();
+
+                        // Pass on
+                        throw e;
+                    }
                 }
             }
         }
-        zis.close();
         throw new IllegalArgumentException("No VBA project found");
     }
     



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


Mime
View raw message