Bug 212685

Summary: NPE in LauncherUtils getTimeStamp
Product: [Eclipse Project] PDE Reporter: James Blackburn <jamesblackburn+eclipse>
Component: UIAssignee: Jakub Jurkiewicz <jakub.jurkiewicz>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: baumanbr
Version: 3.3.1Keywords: bugday, contributed
Target Milestone: ---Flags: baumanbr: review+
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Bug Depends on:    
Bug Blocks: 219119    
Attachments:
Description Flags
Patch attached none

Description James Blackburn CLA 2007-12-11 17:55:34 EST
Build ID: 3.3.1.1

Steps To Reproduce:
Trying to a debugee Eclipse under the PDE, I experienced the following Exception:

Needless to say the launch failed, and a dead but irremovable '[Eclipse Application]' was left in the Debug View.

java.lang.NullPointerException
at org.eclipse.pde.internal.ui.launcher.LauncherUtils.getTimeStamp(LauncherUtils.java:242)
at org.eclipse.pde.internal.ui.launcher.LauncherUtils.handleUseDefault(LauncherUtils.java:270)
at org.eclipse.pde.internal.ui.launcher.LauncherUtils.validateProjectDependencies(LauncherUtils.java:172)
at org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration.validateProjectDependencies(AbstractPDELaunchConfiguration.java:395)
at org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration.preLaunchCheck(AbstractPDELaunchConfiguration.java:301)
at org.eclipse.pde.ui.launcher.EclipseApplicationLaunchConfiguration.preLaunchCheck(EclipseApplicationLaunchConfiguration.java:237)
at org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration.launch(AbstractPDELaunchConfiguration.java:67)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:766)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


More information:
Comment 1 Brian Bauman CLA 2007-12-11 19:12:03 EST
Are you able to reproduce this?  

The code in question comes from calls to java.io.File.  We seem to be getting null when we call File.listFiles().  From the javadoc, it appears this is the case when the File is not a directory (we call isDirectory() prior) or there is an I/O Exception.  I am wondering what is failing in the call...
Comment 2 James Blackburn CLA 2007-12-12 04:06:42 EST
I can't readily reproduce it, but java.io.File documentation (http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#listFiles()) says: "Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs."

And it a quick google seems to show a Java bug filed for the possibility isDirectory() && listFiles==null (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4803836)

It would seem to be the case that if the the directory disappeared (for whatever reason) between the two method calls, null would be returned by listFiles instead of an Exception being thrown or an empty list returned, which is counterintuitive...
Comment 3 Brian Bauman CLA 2007-12-12 10:06:44 EST
I can see this possibly happening with the classfile output directory.  To prevent this (and since it is not readily reproducible), we should put the null check.  Adding bugday tag as this should be a simple fix.
Comment 4 Jakub Jurkiewicz CLA 2008-01-31 05:05:49 EST
Created attachment 88389 [details]
Patch attached

The attached patch adds null checking. I hope this is enough.
Comment 5 Brian Bauman CLA 2008-01-31 09:25:14 EST
Thank you for the patch, Jakub!  I will try to review it today.
Comment 6 Brian Bauman CLA 2008-01-31 11:10:09 EST
Beautiful and elegant :)

Thanks a lot of the patch.  Sounds like a pretty nasty side effect that hopefully no one else will have to deal with now.

If you interested on being added to the PDE wall of over achievers (http://www.eclipse.org/pde/pde-ui/committers/committers.php), please send me a photo with a green leafy back ground and we will make sure it gets up.