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

Bug 314850

Summary: Build fails with NPE and EmptyStackException if a plugin contains "nested extension points"
Product: [Eclipse Project] PDE Reporter: Erdal Karaca <erdal.karaca.de>
Component: UIAssignee: PDE-UI-Inbox <pde-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: a.gurov, curtis.windatt.public, dean.t.roberts, karsten.thoms, pelder.eclipse, stephan.herrmann
Version: 4.0   
Target Milestone: 4.4.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Erdal Karaca CLA 2010-05-28 08:07:09 EDT
Build Identifier: I20100312-1448

I am getting the following exceptions if a plugin.xml will contain "nested extension point" tags.

Example:
   <extension
         point="org.eclipse.ui.perspectives">
         
         <extension
			 point="org.eclipse.ui.perspectives">
		  <perspective
				name="RCP Perspective"
				class="test.Perspective"
				id="test.perspective">
		  </perspective>
	   </extension>
         
      <perspective
            name="RCP Perspective"
            class="test.Perspective"
            id="test.perspective">
      </perspective>
   </extension>

NPE:

java.lang.NullPointerException
	at org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter.validateInternalExtensionAttribute(ExtensionsErrorReporter.java:216)
	at org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter.validateElement(ExtensionsErrorReporter.java:189)
	at org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter.validateExtension(ExtensionsErrorReporter.java:110)
	at org.eclipse.pde.internal.core.builders.ExtensionsErrorReporter.validateContent(ExtensionsErrorReporter.java:75)
	at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.validateFiles(ManifestConsistencyChecker.java:298)
	at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.validateProject(ManifestConsistencyChecker.java:223)
	at org.eclipse.pde.internal.core.builders.ManifestConsistencyChecker.build(ManifestConsistencyChecker.java:157)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

EmptyStackException:

java.util.EmptyStackException
	at java.util.Stack.peek(Unknown Source)
	at org.eclipse.pde.internal.core.plugin.PluginHandler.startElement(PluginHandler.java:60)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at org.eclipse.pde.internal.core.plugin.AbstractExtensionsModel.load(AbstractExtensionsModel.java:85)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.loadModel(WorkspaceModelManager.java:247)
	at org.eclipse.pde.internal.core.WorkspacePluginModelManager.createModel(WorkspacePluginModelManager.java:78)
	at org.eclipse.pde.internal.core.WorkspacePluginModelManager.handleBundleManifestDelta(WorkspacePluginModelManager.java:286)
	at org.eclipse.pde.internal.core.WorkspacePluginModelManager.handleFileDelta(WorkspacePluginModelManager.java:133)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.visit(WorkspaceModelManager.java:160)
	at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:68)
	at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
	at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
	at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
	at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.handleResourceDelta(WorkspaceModelManager.java:125)
	at org.eclipse.pde.internal.core.WorkspaceModelManager.resourceChanged(WorkspaceModelManager.java:113)
	at org.eclipse.jdt.internal.core.DeltaProcessingState$1.run(DeltaProcessingState.java:465)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:460)
	at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:291)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
	at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149)
	at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:327)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1181)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:45)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Reproducible: Always

Steps to Reproduce:
1. Create mail rcp
2. copy any extension points into another extension point (see description)
Comment 1 Curtis Windatt CLA 2012-05-23 15:16:42 EDT
*** Bug 365785 has been marked as a duplicate of this bug. ***
Comment 2 Curtis Windatt CLA 2012-05-23 15:17:06 EDT
*** Bug 304980 has been marked as a duplicate of this bug. ***
Comment 3 Curtis Windatt CLA 2012-05-23 15:17:45 EDT
*** Bug 380364 has been marked as a duplicate of this bug. ***
Comment 4 Stephan Herrmann CLA 2012-08-26 08:54:22 EDT
I'm seeing a similar NPE in the Object Teams tests.

Interestingly, these tests run fine in the IDE, but on the build server they recently started to fail. It may have started to fail when Eclipse webmasters made the build machine faster.

Could this be a timing issue in the PluginModelManager?

In my case each test case adds new plugin projects to the workspace.
Since the PluginModelManager has already been initialized, initializeTables() is short-circuited.
OTOH, I can't easily see the notification mechanism that should update these tables, but I'd guess that EITHER
- notification doesn't pick up the changes quick enough, OR
- some events are dropped entirely?

Would that ring a bill?

PS: No, in my case no nested extension points are involved, but I don't see this in all of the duplicates of this bug, either.
Comment 5 Stephan Herrmann CLA 2012-08-26 10:07:07 EDT
I managed to see the problem in the debugger.

Conditional breakpoint in ctor of ExtensionsErrorReporter:
- trigger only if fModel is initialized to null
- suspend all threads

In the state when this breakpoint triggers I see:
- the 'file' and its enclosing project correctly exist on disk
- the only relevant activity in other threads is JDT indexing
  - under awaitingJobs I see an IndexAllProject for the project in question

Looked promising, but, letting the indexer finish all pending jobs still didn't help: PluginRegistry.findModel(file.getProject()) still answers null...

Does this mean that some notification event got lost?
Comment 6 Stephan Herrmann CLA 2012-08-26 18:14:41 EDT
I can report that I fixed the issue in the Object Teams test suite, but I don't know if any of the other reports could have a similar cause.

For the records:

The NPE occurred because a notification about a new project wasn't sent to the WorkspacePluginModelManager. For this to work correctly, WorkspacePluginModelManager calls:

JavaCore.addPreProcessingResourceChangedListener(this, IResourceChangeEvent.POST_CHANGE);

which means that JDT is now responsible for sending these events.

In my particular case this chain was broken by a simulated restart of the JavaModelManager, a scenario that should never happen outside tests.

Should anyone run into this bug again I recommend to start by looking at org.eclipse.jdt.internal.core.DeltaProcessingState.preResourceChangeListeners, if that list doesn't contain a WorkspacePluginModelManager then we know why the following initialization in ExtensionsErrorReporter fails:
  fModel = PluginRegistry.findModel(file.getProject())
Comment 7 Eclipse Genie CLA 2019-10-03 04:28:14 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Karsten Thoms CLA 2019-10-03 07:05:01 EDT

*** This bug has been marked as a duplicate of bug 435872 ***