commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Eckenfels" <e...@zusammenkunft.net>
Subject [VFS] DelegateFileObject does not prevent NullPointerExceptions
Date Fri, 13 Sep 2013 19:02:29 GMT
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


Mime
View raw message