Project: Eclipse_Platform_UI
Bug 187877 [EFS] Null pointer exception when getting path of FileEditorInput whose file does not exist
Reported: 2007-05-18 14:15:58 | Status: verified fixed

The problem occurs in my plugin when I call FileEditorInput.getPath for a file that has been deleted on disk. This happens when you have an editor open, and then delete its project and choose the option to delete the files on disk. The built-in Eclipse editors do not run into the problem because they present a dialog asking to save or close the file and do not allow any interaction with the file. The stack trace is: java.lang.NullPointerException at org.eclipse.core.internal.filesystem.InternalFileSystemCore.getStore(InternalFileSystemCore.java:104) at org.eclipse.core.filesystem.EFS.getStore(EFS.java:350) at org.eclipse.ui.part.FileEditorInput.getPath(FileEditorInput.java:175) In FileEditorInput.getPath, the code is: final URI locationURI = file.getLocationURI(); IFileStore store = EFS.getStore(locationURI); IResources.getLocationURI is documented to return null if no URI can be determined. I believe that the code above should check for (locationURI == null) and return null. This null pointer exception occurs with Eclipse 3.3M7, but not with 3.2. A workaround for this problem is to not call IEditorInput.getPath() if IEditorInput.exists() returns false.

Files changed in fix:
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileEditorInput.java