You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/07/29 18:36:32 UTC

svn commit: r1693311 - /poi/trunk/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java

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