[VFS] DelegateFileObject does not prevent NullPointerExceptions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[VFS] DelegateFileObject does not prevent NullPointerExceptions

Bernd Eckenfels

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;
             ignoreEvent = false;

I propose to change this like:


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?


To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]