Bug 299850 - [remotesvcs] About RegistrySharedObject#getTargetsFromProperties
Summary: [remotesvcs] About RegistrySharedObject#getTargetsFromProperties
Status: NEW
Alias: None
Product: ECF
Classification: RT
Component: ecf.remoteservices (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: ecf.core-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-16 11:52 EST by Pavel Samolisov CLA
Modified: 2010-01-18 09:12 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Samolisov CLA 2010-01-16 11:52:09 EST
Follow code exists in the class RegistrySharedObject:

final ID[] targets = getTargetsFromProperties(properties);
if (targets == null)
	sendAddRegistration(null, reg);
else
	for (int i = 0; i < targets.length; i++)
		sendAddRegistration(targets[i], reg);

ECF has classes extends RegistrySharedObject wish can have own implementation of method getTargetsFromProperties (i.e. org.eclipse.ecf.internal.provider.xmpp.XMPPRemoteServiceAdapterFactory). This implementations can return null or empty array of IDs.

if its return null we send AddRegistrations to null, if its return empty array (as XMPPRemoteServiceAdapterFactory) we send AddRegistrations to NOBODY.

We should discuss about what should we do. May be we should documented method getTargetsFromProperties (it should return null or no empty array) or we should fix this code, for example:

final ID[] targets = getTargetsFromProperties(properties);
if (targets == null || targets.length == 0)
	sendAddRegistration(null, reg);
Comment 1 Scott Lewis CLA 2010-01-16 12:05:42 EST
Hmmm.  this is an interesting case.  I would be inclined to do as you describe:

final ID[] targets = getTargetsFromProperties(properties);
if (targets == null || targets.length == 0)
    sendAddRegistration(null, reg);

...as I can't think of a decent use case for having getTargetsFromProperties not send out any add registration messages.  If we can think of a decent use case then we can document getTargetsFromProperties as you describe.
Comment 2 Pavel Samolisov CLA 2010-01-16 12:18:13 EST
We can register service with any properties, but without Constants.SERVICE_REGISTRATION_TARGETS
Follows code is contained in the XMPPRemoteServiceAdapterFactory:

List results = new ArrayList();
Object o = properties.get(Constants.SERVICE_REGISTRATION_TARGETS);
if (o != null) {
...
}
return (ID[]) results.toArray(new ID[] {});

if Constants.SERVICE_REGISTRATION_TARGETS is not contains in properties code will return empty array
Comment 3 Scott Lewis CLA 2010-01-16 13:03:16 EST
(In reply to comment #2)
> We can register service with any properties, but without
> Constants.SERVICE_REGISTRATION_TARGETS
> Follows code is contained in the XMPPRemoteServiceAdapterFactory:
> 
> List results = new ArrayList();
> Object o = properties.get(Constants.SERVICE_REGISTRATION_TARGETS);
> if (o != null) {
> ...
> }
> return (ID[]) results.toArray(new ID[] {});
> 
> if Constants.SERVICE_REGISTRATION_TARGETS is not contains in properties code
> will return empty array

Oh yes, now I remember.  

The XMPP provider doesn't support sending to a 'group' when service registration targets is not set...because there is no pre-defined group.  So if null is passed to the send* methods the XMPP provider will throw an IOException.
Comment 4 Pavel Samolisov CLA 2010-01-16 13:12:20 EST
Yes. it is, bug we has not only XMPP provider and we have potential bug for other providers and especially for new (not development) providers. I think we should document this aspect.
Comment 5 Scott Lewis CLA 2010-01-18 09:12:40 EST
(In reply to comment #4)
> Yes. it is, bug we has not only XMPP provider and we have potential bug for
> other providers and especially for new (not development) providers. I think we
> should document this aspect.

I agree.  I can't do it myself immediately due to other commitments, but please remind and I will get to it when I can.