Benjamin Bentmann created KARAF-4899:
----------------------------------------
Summary: FeatureService dissociates concurrently installed bundles
from their region
Key: KARAF-4899
URL: https://issues.apache.org/jira/browse/KARAF-4899
Project: Karaf
Issue Type: Bug
Components: karaf-feature
Affects Versions: 4.0.8, 4.0.5
Reporter: Benjamin Bentmann
Take the following scenario:
# thread A executes {{FeatureServiceImpl.doProvision()}} and just completed the
call to {{getDeploymentState()}}
# thread B calls {{BundleContext.installBundle()}}, as part of processing the
resulting {{BundleEvent.INSTALLED}} event the {{RegionBundleEventHook}} will
associate the new bundle with a region
# thread A continues {{doProvision()}} and eventually calls
{{FeatureServiceImpl.replaceDigraph()}}, due to having used the bundle sets
recorded in the deployment state from step 1 (which is outdated since thread B
installed a new bundle) the new region digraph fails to mention the newly
installed bundle from step 2, effectively making it region-less.
In case that description is not clear enough, example call stacks of the racing
threads, thread A:
{noformat}
Thread [pool-2-thread-1]
org.apache.karaf.features.internal.service.FeaturesServiceImpl.getDeploymentState(org.apache.karaf.features.internal.service.State)
line: 1103
org.apache.karaf.features.internal.service.FeaturesServiceImpl.doProvision(java.util.Map<java.lang.String,java.util.Set<java.lang.String>>,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,org.apache.karaf.features.FeatureState>>,
org.apache.karaf.features.internal.service.State,
java.util.EnumSet<org.apache.karaf.features.FeaturesService.Option>,
java.lang.String) line: 1174
org.apache.karaf.features.internal.service.FeaturesServiceImpl$1.call()
line: 1074
java.util.concurrent.FutureTask<V>.run() line: 266
java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker)
line: 1142
java.util.concurrent.ThreadPoolExecutor$Worker.run() line: 617
java.lang.Thread.run() line: 745
{noformat}
thread B:
{noformat}
Daemon System Thread [RMI TCP Connection(1)-192.168.99.1]
org.apache.felix.framework.Felix.installBundle(org.osgi.framework.Bundle,
java.lang.String, java.io.InputStream) line: 3004
org.apache.felix.framework.BundleContextImpl.installBundle(java.lang.String,
java.io.InputStream) line: 167
org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.installBundle(java.lang.String,
byte[]) line: 107
{noformat}
The sporadic failures resulting from this race condition likely vary, in our
case of a pax-exam-based test, the consequence is
{{org.ops4j.pax.swissbox.tracker.ServiceLookupException: gave up waiting for
service org.ops4j.pax.exam.ProbeInvoker}} errors caused by the fact that the
bundle events (in particular {{STARTED}}) for the test probe bundle don't make
it to the registered listeners because the test probe bundle became region-less
whereas the listener (like everything else) belongs to the "root" region.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)