aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-07-29 16:36:32 +0000
committerNick Burch <nick@apache.org>2015-07-29 16:36:32 +0000
commit7caf5eda4c642fcb8bdf223ff71f8539e8ffab7b (patch)
tree502f7553b78713e67e593f235a860ea775f36b42 /src/java
parent77098e5e3e6953c3f6cd9f5c7d381d8536e238f8 (diff)
downloadpoi-7caf5eda4c642fcb8bdf223ff71f8539e8ffab7b.tar.gz
poi-7caf5eda4c642fcb8bdf223ff71f8539e8ffab7b.zip
Avoid NPE in cleanup if NPOIFSFileSystem is opened on a locked File under Windows, and add a note on Java 7 possible cleanup #58098
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1693311 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
index 9817c3d818..0bac7e1c74 100644
--- a/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
+++ b/src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
@@ -232,20 +232,21 @@ public class NPOIFSFileSystem extends BlockStore
// 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;
}
}