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

Bug 313484

Summary: NullPointerException in ProvCommandProvider (p2.console) when profile doesn't exist
Product: [Eclipse Project] Equinox Reporter: Katya Stoycheva <katya.stoycheva>
Component: p2Assignee: P2 Inbox <equinox.p2-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: pascal
Version: unspecified   
Target Milestone: 3.7 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
ProvCommandProvider adapted to show meaningful message when profile is missing instead of throwing NPE pascal: iplog+

Description Katya Stoycheva CLA 2010-05-19 04:54:52 EDT
Build Identifier: N20100512-2000

When trying to install a bundle via prov command (ProvCommandProvider), NullPointerException is produced. The reason is lack of registered profiles but the command expects at least 1 profile. When there's no profile, command returns null for IStatus. This seems unexpected by ProvCommandProvider - it shows to the end user the exception instead of some meaningful message what went wrong.

Here is the code that causes the exception:
...
IStatus s = ProvisioningHelper.install(agent, iu, version, ProvisioningHelper.getProfile(agent, profileId), new NullProgressMonitor());
...
if (s.isOK())
...

Reproducible: Always

Steps to Reproduce:
1.Download and unzip Equinox (http://download.eclipse.org/equinox/drops/N20100512-2000/index.php)
2.Start it in root folder (equinox) using 
java -jar plugins/org.eclipse.osgi_3.6.0.N20100512-2000.jar -configuration configuration –console
3.Setup dropins folder in config.ini:
org.eclipse.equinox.p2.reconciler.dropins.directory=dropins
4.Describe all plugins (and start them) in 
Equinox/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
5.Execute the command
provinstall abc 123
6. Observe the exception:
osgi> provinstall com.ibm.icu.source_4.0.1.v20090822 4.0.1
java.lang.NullPointerException
at org.eclipse.equinox.internal.p2.console.ProvCommandProvider._provinstall(ProvCommandProvider.java:136)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:155)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:303)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:288)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(FrameworkConsole.java:224)
at java.lang.Thread.run(Unknown Source)
Comment 1 Katya Stoycheva CLA 2010-05-19 04:57:13 EDT
Created attachment 169069 [details]
ProvCommandProvider adapted to show meaningful message when profile is missing instead of throwing NPE
Comment 2 Pascal Rapicault CLA 2010-11-02 17:31:05 EDT
Patch released in HEAD for build toward 3.7 M4