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

Bug 319126

Summary: [RemoteSvcs] Wildcard causes IRemoteServiceContainerAdapter.registerRemoteService(String[], Object, Dictionary) to fail
Product: [RT] ECF Reporter: Markus Kuppe <bugs.eclipse.org>
Component: ecf.providersAssignee: Markus Kuppe <bugs.eclipse.org>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: slewis
Version: unspecified   
Target Milestone: 3.3.0RC1   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 319313    
Attachments:
Description Flags
mylyn/context/zip
none
Handle String[]{"*"} none

Description Markus Kuppe CLA 2010-07-07 09:56:43 EDT
!ENTRY org.eclipse.ecf.osgi.services.distribution 4 0 2010-07-07 01:39:32.258
!MESSAGE 
!STACK 0
org.osgi.framework.ServiceException: Exception in org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.event()
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyEventHooksPrivileged(ServiceRegistry.java:1138)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:743)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:711)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:129)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:206)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:507)
	at org.eclipse.ecf.tests.osgi.services.distribution.AbstractDistributionTest.registerService(AbstractDistributionTest.java:164)
	at org.eclipse.ecf.tests.osgi.services.distribution.AbstractDistributionTest.registerService(AbstractDistributionTest.java:169)
	at org.eclipse.ecf.tests.osgi.services.distribution.AbstractRemoteServiceAccessTest.testGetRemoteServiceReference(AbstractRemoteServiceAccessTest.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.pluginbuilder.autotestsuite.application.AutoTestRunner.run(AutoTestRunner.java:115)
	at org.pluginbuilder.autotestsuite.application.AutoTestApplication.runAllJUnit3Tests(AutoTestApplication.java:260)
	at org.pluginbuilder.autotestsuite.application.AutoTestApplication.runAllJUnitTestsOnUIThread(AutoTestApplication.java:175)
	at org.pluginbuilder.autotestsuite.application.AutoTestApplication.runHeadless(AutoTestApplication.java:159)
	at org.pluginbuilder.autotestsuite.application.AutoTestApplication.run(AutoTestApplication.java:96)
	at org.pluginbuilder.autotestsuite.application.AutoTestApplication.start(AutoTestApplication.java:69)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.IllegalArgumentException: Service is not valid: *
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.registerRemoteService(RegistrySharedObject.java:295)
	at org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.handleRegisteredServiceEvent(EventHookImpl.java:118)
	at org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.event(EventHookImpl.java:62)
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyEventHooksPrivileged(ServiceRegistry.java:1129)
	... 41 more

	
org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.checkServiceClass(String[], Object) throws an exception if called with the remote service wildcard.
Comment 1 Markus Kuppe CLA 2010-07-07 09:59:37 EDT
Attached context shows the classes/methods involved
Comment 2 Markus Kuppe CLA 2010-07-07 09:59:39 EDT
Created attachment 173651 [details]
mylyn/context/zip
Comment 3 Scott Lewis CLA 2010-07-07 10:04:01 EDT
Please describe/detail the input parameters used for this call.
Comment 4 Markus Kuppe CLA 2010-07-07 12:24:32 EDT
One of the test that fails because of this issue is GenericRemoteServiceRegisterTest(AbstractRemoteServiceRegisterTest).testRegisterOnCreatedServer() line: 81	

The problem is in org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.checkServiceClass(String[], Object) if called
with String[]{"*"} which fails with a ClassNotFoundException for "*". We might have to add logic to accept "*" in org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.checkServiceClass(String[], Object)
Comment 5 Markus Kuppe CLA 2010-07-07 12:31:06 EDT
Alternatively we might want to change org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.handleRegisteredServiceEvent(ServiceReference, Collection) to resolve "*" to the actual service interface(s) in org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.getExportedInterfaces(ServiceReference).
Comment 6 Markus Kuppe CLA 2010-07-07 12:58:05 EDT
After some more investigation the underlying problem might be relatively simple. org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.getExportedInterfaces(ServiceReference) does not handle a service wildcard nested inside a String[].
Comment 7 Scott Lewis CLA 2010-07-07 13:03:55 EDT
(In reply to comment #6)
> After some more investigation the underlying problem might be relatively
> simple.
> org.eclipse.ecf.internal.osgi.services.distribution.EventHookImpl.getExportedInterfaces(ServiceReference)
> does not handle a service wildcard nested inside a String[].

Yeah.  It does handle "*" (i.e. rather than new String[] { "*" }).  As I *remember*, the specification (for remote services) specifies the "*" String as indicating the wildcard...I don't recall it saying anything about new String[] { "*" }.  So...in the current implementation new String[] { "*" } isn't supported (as you've found).

We could pretty easily support it...although I'm not sure if that would be specification compliant or not.  Unless I'm misremembering (which is possible, since I don't have the spec committed to memory yet :) I think the spec is ambiguous about new String[] { "*" }.
Comment 8 Markus Kuppe CLA 2010-07-07 13:09:07 EDT
Created attachment 173680 [details]
Handle String[]{"*"}
Comment 9 Scott Lewis CLA 2010-07-07 13:14:47 EDT
(In reply to comment #8)
> Created an attachment (id=173680) [details]
> Handle String[]{"*"}

Although this patch certainly allows us to support new String[] { "*" }, I think we need to determine (somehow) whether this is going to introduce a problem WRT remote service spec compliance.  One reason...*now* the impl will also accept (e.g.):

new String[] { "IFoo", "*" };

and this might be considered a problem (by some).

In any event, it's not a big deal to me, but I just don't want to introduce things without checking that might get us dinged on spec compliance (no matter how trivial).
Comment 10 Markus Kuppe CLA 2010-07-08 04:28:07 EDT
Removing R-OSGi tag as this also affects other remote service containers
Comment 11 Markus Kuppe CLA 2010-07-08 04:32:25 EDT
Released a change in org.eclipse.ecf.tests.osgi.services.distribution.AbstractRemoteServiceAccessTest.getServiceProperties() to HEAD that replaces the String[]{SERVICE_EXPORTED_INTERFACES_WILDCARD} from the service properties with just SERVICE_EXPORTED_INTERFACES_WILDCARD.
Comment 12 Markus Kuppe CLA 2010-07-31 06:14:29 EDT
Fixed in HEAD (as per previous comment)
Comment 13 Markus Kuppe CLA 2010-09-11 12:24:24 EDT
Does this need a backport for 3.3.1?
Comment 14 Scott Lewis CLA 2010-09-11 19:56:50 EDT
(In reply to comment #13)
> Does this need a backport for 3.3.1?

Yes.  Please apply this fix to the Release_3_3 stream, and I'll do another Release_3_3 sdk build for our contribution to Helios maintenance build on Monday next (9/13).  Please just let me know on this bug when it's been applied to Release_3_3 stream.
Comment 15 Markus Kuppe CLA 2010-09-12 07:03:40 EDT
(In reply to comment #14)
> Yes.  Please apply this fix to the Release_3_3 stream, and I'll do another
> Release_3_3 sdk build for our contribution to Helios maintenance build on
> Monday next (9/13).  Please just let me know on this bug when it's been applied
> to Release_3_3 stream.

Backported to Release_3_3 and spun off a new test build https://build.ecf-project.org/hudson/job/L-Release_3_3-sdk.tests.feature/16/
Comment 16 Markus Kuppe CLA 2010-09-12 07:04:12 EDT
Changing target milestone