[
https://issues.apache.org/jira/browse/FELIX-3096?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Richard S. Hall resolved FELIX-3096.
------------------------------------
Resolution: Fixed
It should be working now in trunk. We avoid holding the bundle lock for adding
listeners by double checking if the bundle context is still valid before adding
the listener, which is guaranteed to happen before a bundle's listeners are
removed when it is stopped or fail if it happens after.
Please close this issue if satisfied, thanks.
> Could not add FrameworkListener from ServiceListener
> ----------------------------------------------------
>
> Key: FELIX-3096
> URL: https://issues.apache.org/jira/browse/FELIX-3096
> Project: Felix
> Issue Type: Bug
> Affects Versions: framework-3.2.2
> Reporter: Vlad Arkhipov
> Assignee: Richard S. Hall
> Priority: Critical
> Fix For: framework-4.0.0
>
>
> It's now impossible to add a FrameworkListener from ServiceListener in 3.2.x,
> worked in 3.0.9. The code below hangs in addFrameworkListener when it tries
> to acquire a global lock on the framework bundle.
> Framework framework = ...
> framework.init();
> final BundleContext ctx = framework.getBundleContext();
> ctx.addServiceListener(new ServiceListener() {
> public void serviceChanged(ServiceEvent event) {
> if (...) {
> ctx.addFrameworkListener(new FrameworkListener() {
> public void frameworkEvent(FrameworkEvent event) {
> System.out.println(event);
> }
> });
> }
> }
> });
> StartLevel sl = (StartLevel)
> ctx.getService(ctx.getServiceReference(StartLevel.class.getName()));
> // Install bundles, set start level.
> ...
> framework.start();
> framework.waitForStop();
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira