poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1693311 - /poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
Date Wed, 29 Jul 2015 16:36:32 GMT
Author: nick
Date: Wed Jul 29 16:36:32 2015
New Revision: 1693311

URL: http://svn.apache.org/r1693311
Log:
Avoid NPE in cleanup if NPOIFSFileSystem is opened on a locked File under Windows, and add
a note on Java 7 possible cleanup #58098

Modified:
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java?rev=1693311&r1=1693310&r2=1693311&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java Wed Jul 29 16:36:32
2015
@@ -232,20 +232,21 @@ public class NPOIFSFileSystem extends Bl
           // Now process the various entries
           readCoreContents();
        } catch(IOException e) {
-          if(closeChannelOnError) {
-             channel.close();
+          // Until we upgrade to Java 7, and can do a MultiCatch, we 
+          //  need to keep these two catch blocks in sync on their cleanup
+          if (closeChannelOnError && channel != null) {
+              channel.close();
+              channel = null;
           }
           throw e;
        } catch(RuntimeException e) {
           // Comes from Iterators etc.
           // TODO Decide if we can handle these better whilst
           //  still sticking to the iterator contract
-          if(closeChannelOnError) {
-              if (channel != null) {
-                  channel.close();
-                  channel = null;
-              }
-          }
+           if (closeChannelOnError && channel != null) {
+               channel.close();
+               channel = null;
+           }
           throw e;
        }
     }



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


Mime
View raw message