Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316936

Summary: [Help][Context] NPE on ContextFile
Product: [Eclipse Project] Platform Reporter: Angel Vera <arvera>
Component: User AssistanceAssignee: platform-ua-inbox <platform-ua-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: cgold
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Angel Vera CLA 2010-06-15 11:59:53 EDT
While debugging a problem I found that there was a NPE thrown in ContextFile.hashCode because for whatever reason file was null. I am not sure in which situations this would happen, but I wonder if it can be handled in a better manner, perhaps printing out the bundleID that caused the error.
Comment 1 Chris Goldthorpe CLA 2010-06-15 13:55:32 EDT
Can you attach a stack trace?
Comment 2 Chris Goldthorpe CLA 2011-02-02 19:06:21 EST
Are you still seeing the problem, if so can you include a stack trace?
Comment 3 Angel Vera CLA 2011-02-03 11:01:47 EST
Sorry I would be hard for me to provide a stacktrace at this time. Is it possible to just do a null check and print something more useful?
Comment 4 Chris Goldthorpe CLA 2011-02-03 13:03:13 EST
The constructor for ContextFile() is only called from one place so I was able to determine that the only way file could be null would be if in the extension point declaration for the context is missing a file attribute. I verified that if I changed the code to set file to null the NPE you saw would occur.

Omitting the file attribute in a <context> element in plugin.xml causes an error at build time. The only way I could think that this situation could occur would be to modify plugin.xml outside of the build environment.

If I add a null pointer check to hashCode() an NPE will just thrown later when attempting to open the file. My inclination is to close this bug as WONTFIX since it represents a situation that would only occur if the build tools were bypassed when creating the plug-in and the extension does not match the schema, in which case the exception would give a clue as to how to fix the problem.
Comment 5 Angel Vera CLA 2011-02-03 13:58:12 EST
I understand your assessment.