Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338102 - [remoteserviceadmin] NPE with getFrameworkUUID
Summary: [remoteserviceadmin] NPE with getFrameworkUUID
Status: RESOLVED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.remoteservices (show other bugs)
Version: 3.5.0   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: ecf.core-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 10:31 EST by Martin Petzold CLA
Modified: 2011-02-24 12:38 EST (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 Martin Petzold CLA 2011-02-24 10:31:51 EST
->  AbstractTopologyManager should be compatible with Eclipse (Equinox) 3.6.1

-----

Caused by: java.lang.NullPointerException
    at
org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractTopologyManager.getFrameworkUUID(AbstractTopologyManager.java:59)
    at
org.eclipse.ecf.internal.osgi.services.distribution.BasicTopologyManager.getEndpointListenerScope(BasicTopologyManager.java:49)
    at
org.eclipse.ecf.internal.osgi.services.distribution.BasicTopologyManager.start(BasicTopologyManager.java:64)
    at
org.eclipse.ecf.internal.osgi.services.distribution.Activator.start(Activator.java:101)
    at
org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
    at java.security.AccessController.doPrivileged(Native Method)
    at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)

----- my woraround at the moment

	private String uuid = null;

	[...]

	public AbstractTopologyManager(BundleContext context) {
		this.context = context;
		
		this.uuid = UUID.randomUUID().toString();
	}

	protected BundleContext getContext() {
		return context;
	}

	protected String getFrameworkUUID() {
		if(Activator.getDefault() != null) {
			return Activator.getDefault().getFrameworkUUID();
		} else {
			return this.uuid;
		}
	}

	[...]
Comment 1 Scott Lewis CLA 2011-02-24 10:38:01 EST
Martin...I suspect that if the org.eclipse.ecf.osgi.services.remoteserviceadmin bundle starts correctly (see the new proxy bundle issue) that Activator.getDefault().getFrameworkUUID() will not return null and you will not get an NPE).  I think it's probably returning null from Activator.getDefault()...which should not happen if the bundle is started correctly/successfully.

I should, however, guard against the possibility that getDefault() returns null (since getFrameworkUUID() should be thread safe), so I will add such a guard to this code shortly/later this morning.
Comment 2 Martin Petzold CLA 2011-02-24 10:59:40 EST
This bug would then be connected to https://bugs.eclipse.org/bugs/show_bug.cgi?id=338107.
Comment 3 Markus Kuppe CLA 2011-02-24 11:02:34 EST
(In reply to comment #2)
> This bug would then be connected to
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=338107.

How is this bug related to bug #338107? This one is about an NPE in AbstractTopologyManager, while bug #338107 is about PDE not compiling/including classes (e.g. AbstractTopologyManager) in a (local) build.
Comment 4 Martin Petzold CLA 2011-02-24 11:13:37 EST
Because (In reply to comment #3)
> (In reply to comment #2)
> > This bug would then be connected to
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=338107.
> 
> How is this bug related to bug #338107? This one is about an NPE in
> AbstractTopologyManager, while bug #338107 is about PDE not compiling/including
> classes (e.g. AbstractTopologyManager) in a (local) build.

Sorry again, it's not connected. But I think Scott is right, it's about the bundle not startet correctly (start levels perhaps).
Comment 5 Martin Petzold CLA 2011-02-24 12:33:16 EST
This is most likely fixed, at least due to fix of bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=338107

...and the bugs where connected somehow ;-)
Comment 6 Scott Lewis CLA 2011-02-24 12:38:11 EST
(In reply to comment #5)
> This is most likely fixed, at least due to fix of bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=338107
> 
> ...and the bugs where connected somehow ;-)

Just for your information...they were connected since the remoteserviceadmin bundle wasn't starting properly in your environment, the call in AbstractTopologyManager to Activator.getDefault() was returning null, and so the line Activator.getDefault().getFrameworkUUID() was throwing a NPE.