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

Bug 338102

Summary: [remoteserviceadmin] NPE with getFrameworkUUID
Product: [RT] ECF Reporter: Martin Petzold <mpetzold>
Component: ecf.remoteservicesAssignee: ecf.core-inbox <ecf.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bugs.eclipse.org, slewis
Version: 3.5.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

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.