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
This commit is contained in:
parent
b6b3853330
commit
ca35f594a7
@ -232,20 +232,21 @@ public class NPOIFSFileSystem extends BlockStore
|
|||||||
// Now process the various entries
|
// Now process the various entries
|
||||||
readCoreContents();
|
readCoreContents();
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
if(closeChannelOnError) {
|
// Until we upgrade to Java 7, and can do a MultiCatch, we
|
||||||
channel.close();
|
// need to keep these two catch blocks in sync on their cleanup
|
||||||
|
if (closeChannelOnError && channel != null) {
|
||||||
|
channel.close();
|
||||||
|
channel = null;
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} catch(RuntimeException e) {
|
} catch(RuntimeException e) {
|
||||||
// Comes from Iterators etc.
|
// Comes from Iterators etc.
|
||||||
// TODO Decide if we can handle these better whilst
|
// TODO Decide if we can handle these better whilst
|
||||||
// still sticking to the iterator contract
|
// still sticking to the iterator contract
|
||||||
if(closeChannelOnError) {
|
if (closeChannelOnError && channel != null) {
|
||||||
if (channel != null) {
|
channel.close();
|
||||||
channel.close();
|
channel = null;
|
||||||
channel = null;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user