You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Bernd Eckenfels <ec...@zusammenkunft.net> on 2013/09/13 21:02:29 UTC
[VFS] DelegateFileObject does not prevent NullPointerExceptions
Hello,
while working with VirtualFileSystemProvider (which seems to be the only
user of DelegateFileObject) I noticed that if a delegated file is created
without a backing file some methods (like doCreateFolder()) do not
properly catch this condition. It produces a rather ugly NPE.
Some methods act sane on file == null, but a lot of the delegating methods
look like:
protected void doCreateFolder() throws Exception
{
ignoreEvent = true;
try
{
file.createFolder();
}
finally
{
ignoreEvent = false;
}
I propose to change this like:
getFileOrThrow().crateFolder();
with a FileSystemException "not attached".
Alternatively one could set a default placeholder file (instead of null),
which can then do some different handlings. But that requires to change
the places where == null checks are today.
Instead of trying an exceptio we can also try to have a default behaviour
in more of the places. (For example returning a empty read only content
dummy). What do you think? Want me to open a Jira?
Gruss
Bernd
--
http://www.zusammenkunft.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org