Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 441377 - regression: NPE when passing properties to an Framework instance created from the FrameworkFactory
Summary: regression: NPE when passing properties to an Framework instance created from...
Status: VERIFIED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Framework (show other bugs)
Version: 3.10.0 Luna   Edit
Hardware: All All
: P3 blocker (vote)
Target Milestone: Luna SR1   Edit
Assignee: Thomas Watson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-07 14:32 EDT by Raymond Auge CLA
Modified: 2014-09-03 14:07 EDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raymond Auge CLA 2014-08-07 14:32:47 EDT
If the Map of properties passed to the framework instance created from a FrameworkFactory contains an entry with a null value, the framework will crash with an NPE.

Steps to reproduce:

java.util.ServiceLoader<FrameworkFactory> loader = java.util.ServiceLoader.load(FrameworkFactory.class);
		
Map<String, String> properties = new HashMap<String, String>();
		
properties.put("blah", null);
		
Framework newFramework = loader.iterator().next().newFramework(properties);
Comment 1 Thomas Watson CLA 2014-08-07 14:36:23 EDT
Need to fix this for Luna SR1 since it is a regression.

There are two fixes needed here:

1) prevent the NPE

2) make sure that when a key is supplied with a null value then BundleContext.getProperty (and EnvironmentInfo.getProperty) return null for the supplied key.
Comment 3 Stephan Herrmann CLA 2014-09-02 12:20:31 EDT
This fix seems to be responsible for a breakage of the Object Teams build. Since upgrading to RC2 I get:

     [java] java.lang.NullPointerException
     [java]     at org.eclipse.osgi.internal.framework.EquinoxConfiguration<init>(EquinoxConfiguration.java:207)
     [java]     at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:69)
     [java]     at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
     [java]     at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:299)
     [java]     at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     [java]     at java.lang.reflect.Method.invoke(Method.java:483)
     [java]     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
     [java]     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
     [java]     at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
     [java]     at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
     [java] An error has occurred. See the log file
     [java] null.
     [java] Java Result: 13
Comment 4 Stephan Herrmann CLA 2014-09-02 12:24:37 EDT
See that the first line in the constructor checks:
  initialConfiguration == null ?

just a few lines down you assume non-null without checking:
  for (Map.Entry<String, ?> initialEntry : initialConfiguration.entrySet()) {

JDT would have told you, if you let it ...
Comment 5 Thomas Watson CLA 2014-09-02 13:38:33 EDT
Working a fix now.
Comment 6 Thomas Watson CLA 2014-09-02 13:59:32 EDT
This bug introduced the code that caused the NPE, but it is also the fix to bug 441681 that allowed EclipseStarter to pass null into the constructor of Equinox.
Comment 8 Stephan Herrmann CLA 2014-09-02 17:43:31 EDT
The Object Teams build has finished successfully using M20140902-1430.

Thanks!
Comment 9 Thomas Watson CLA 2014-09-02 19:44:50 EDT
I also confirmed this fix.  Thanks for reporting Stephan and sorry for the trouble.
Comment 10 Konstantin Komissarchik CLA 2014-09-03 14:07:14 EDT
I have also verified that the issue in Comment #3 has been addressed. I used RC2a build. Many thanks for making the fix available before the next milestone.