Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354066 - NPE in core when exiting
Summary: NPE in core when exiting
Status: CLOSED DUPLICATE of bug 353815
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 21:48 EDT by Miles Parker CLA
Modified: 2011-08-08 09:55 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miles Parker CLA 2011-08-05 21:48:46 EDT
This is probably a bit of an edge case, but I'm getting an NPE when I exit out of a hosted runtime. I'm probably missing something from the set of plugins that PDE is expecting to have available, but I don't have any missing dependencies.

This is the exception I'm seeing:

java.lang.NullPointerException
	at org.eclipse.pde.internal.core.target.P2TargetUtils.getAgent(P2TargetUtils.java:300)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.getProfileRegistry(P2TargetUtils.java:775)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.cleanOrphanedTargetDefinitionProfiles(P2TargetUtils.java:159)
	at org.eclipse.pde.internal.core.PDECore$1.saving(PDECore.java:258)
	at org.eclipse.core.internal.resources.SaveManager.executeLifecycle(SaveManager.java:382)
	at org.eclipse.core.internal.resources.SaveManager$1.run(SaveManager.java:191)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.resources.SaveManager.broadcastLifecycle(SaveManager.java:194)
	at org.eclipse.core.internal.resources.SaveManager.save(SaveManager.java:1129)
	at org.eclipse.core.internal.resources.Workspace.save(Workspace.java:2375)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor$5.run(IDEWorkbenchAdvisor.java:508)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)


Looking at the code, it it assuming that there is in fact a provider available. Perhaps it should be throwing another exception in this case?

	public static IProvisioningAgent getAgent() throws CoreException {
		//Is there already an agent for this location?
		String filter = "(locationURI=" + String.valueOf(AGENT_LOCATION) + ")"; //$NON-NLS-1$//$NON-NLS-2$
		ServiceReference[] serviceReferences = null;
		BundleContext context = PDECore.getDefault().getBundleContext();
		try {
			serviceReferences = context.getServiceReferences(IProvisioningAgent.SERVICE_NAME, filter);
			if (serviceReferences != null) {
				return (IProvisioningAgent) context.getService(serviceReferences[0]);
			}
		} catch (InvalidSyntaxException e) {
			// ignore
		} finally {
			if (serviceReferences != null)
				context.ungetService(serviceReferences[0]);
		}

		IProvisioningAgentProvider provider = (IProvisioningAgentProvider) PDECore.getDefault().acquireService(IProvisioningAgentProvider.SERVICE_NAME);
		try {
			IProvisioningAgent agent = provider.createAgent(AGENT_LOCATION);
			// turn off the garbage collector for the PDE agent.  GC is managed on a coarser grain
			GarbageCollector garbageCollector = (GarbageCollector) agent.getService(GarbageCollector.class.getName());
			if (garbageCollector != null) {
				garbageCollector.stop();
			}
			return agent;
		} catch (ProvisionException e) {
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, Messages.IUBundleContainer_7, e));
		}
	}
Comment 1 Curtis Windatt CLA 2011-08-08 09:55:38 EDT

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