[
https://issues.jboss.org/browse/JBOSGI-479?page=com.atlassian.jira.plugin...
]
David Bosschaert commented on JBOSGI-479:
-----------------------------------------
The performance impact should be negligible. The synchronization is in most cases on
different objects as the canonical name of the service is used to synchronize. So if the
services have a difference canonical name they don't wait on each other.
The trick is here in the use of the interned string which guarantees the same string
object is the string values being interned are the same.
I don't think that having the client retry the registration on a runtime exception is
a good idea since this is not part of the documented BundleContext.registerService API.
Race condition when registering services in multiple threads
------------------------------------------------------------
Key: JBOSGI-479
URL:
https://issues.jboss.org/browse/JBOSGI-479
Project: JBoss OSGi
Issue Type: Bug
Security Level: Public(Everyone can see)
Reporter: David Bosschaert
Assignee: David Bosschaert
When registering multiple services with the same service name a race condition occurs.
This is exposed when running the Service Performance tests (e.g.
org.jboss.osgi.test.performance.service.arq.Service100TestCase).
The problem boils down to the fact that two threads race to obtain a service controller
for the same name. One of them wins, the other fails with this exception:
org.jboss.msc.service.DuplicateServiceException: Service
jbosgi.service."org.jboss.osgi.test.performance.service.SvcCls1" is already
registered
at
org.jboss.msc.service.ServiceRegistrationImpl.setInstance(ServiceRegistrationImpl.java:154)
at
org.jboss.msc.service.ServiceControllerImpl.startInstallation(ServiceControllerImpl.java:226)
at org.jboss.msc.service.ServiceContainerImpl.install(ServiceContainerImpl.java:560)
at org.jboss.msc.service.ServiceTargetImpl.install(ServiceTargetImpl.java:201)
at
org.jboss.msc.service.ServiceControllerImpl$ChildServiceTarget.install(ServiceControllerImpl.java:2194)
at org.jboss.msc.service.ServiceBuilderImpl.install(ServiceBuilderImpl.java:307)
at
org.jboss.osgi.framework.internal.ServiceManagerPlugin.registerService(ServiceManagerPlugin.java:180)
at
org.jboss.osgi.framework.internal.AbstractBundleContext.registerService(AbstractBundleContext.java:305)
at
org.jboss.osgi.framework.internal.AbstractBundleContext.registerService(AbstractBundleContext.java:297)
at
org.jboss.osgi.test.performance.service.CreateAndLookupBenchmark.runThread(CreateAndLookupBenchmark.java:79)
at
org.jboss.osgi.test.performance.service.CreateAndLookupBenchmark.runThread(CreateAndLookupBenchmark.java:41)
at
org.jboss.osgi.test.performance.AbstractThreadedBenchmark$1.run(AbstractThreadedBenchmark.java:91)
at java.lang.Thread.run(Thread.java:680)
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira