[ 
https://issues.apache.org/jira/browse/FELIX-3096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13094778#comment-13094778
 ] 

Richard S. Hall commented on FELIX-3096:
----------------------------------------

I think this issue is different than FELIX-3000. The system bundle lock is 
being held because it is in the middle of being started, but on the start level 
thread (which is how the framework ultimately starts up its bundles) the outer 
listener code is being invoked, which requires the system bundle's lock to add 
a listener.

Technically, this is correct. It is a perfect example of what not to do, block 
the incoming thread and then make a call back into the framework on another 
thread. Of course, this one happens due to how the framework starts 
up...perhaps one approach would be to not use the start level thread on the 
initial start up of the framework so the startup would all happen on the same 
thread and thus the lock could be reentered.

I'll have to think about it.

> 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
>            Priority: Critical
>
> 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

        

Reply via email to