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

Bug 337646

Summary: NPE in BundleErrorReporter when trying to report ignored build path problem
Product: [Eclipse Project] PDE Reporter: Stephan Herrmann <stephan.herrmann>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 3.7   
Target Milestone: 3.7 M6   
Hardware: All   
OS: All   
Whiteboard:

Description Stephan Herrmann CLA 2011-02-19 12:22:34 EST
Steps (using SDK 3.7 M5):
- check out project org.eclipse.jdt.core
  (I assume any plug-in project with the following setting will do:
     compilers.p.build.source.library=2
  )
- add a source folder "contrib", do not update build.properties

The BundleErrorReporter will try to report:
  "contrib/ is not included in any "source.*" build entry"

However, while trying to report it will die with an NPE:

java.lang.NullPointerException
        at org.eclipse.pde.internal.core.builders.BuildErrorReporter.reportErrors(BuildErrorReporter.java:1068)
        at org.eclipse.pde.internal.core.builders.BuildErrorReporter.validate(BuildErrorReporter.java:164)
        at org.eclipse.pde.internal.core.builders.ErrorReporter.validateContent(ErrorReporter.java:127)
        at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.validateBuildProperties(ManifestConsistencyChecker.java:316)
        at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.validateProject(ManifestConsistencyChecker.java:231)
        at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.build(ManifestConsistencyChecker.java:157)


Cause: report(..) will return null if the problem severity is IGNORED,
but reportErrors(..) does not catch this null but happily proceeds until ...


Naturally, this occurred while working on bug 186342 to support detecting
NPEs at compile time :)
In the future the return of report(..) should be declared as 
  "@Nullable IMarker"
which will cause marker.setAttribute(..) to be flagged as an error.
Simple as that.
Comment 1 Curtis Windatt CLA 2011-02-22 12:24:04 EST
Fixed in HEAD see BundleErrorReporter.java.  Added javadoc comments to the report methods to remind callers.  PDE is 1.4 compliant and we do not use annotations.