You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2007/06/28 11:56:26 UTC

[jira] Created: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

EventDispatcher class not reusable in same class loader for multiple Felix instances
------------------------------------------------------------------------------------

                 Key: FELIX-314
                 URL: https://issues.apache.org/jira/browse/FELIX-314
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: 0.8.0
            Reporter: Felix Meschberger
             Fix For: 1.0.0


Consider this use case:

   Felix felix = new Felix();
   felix.start(props, null);
   felix.shutdown();

   felix = new Felix();
   felix.start(props, null);
   felix.shutdown();

The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.

The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.

I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger closed FELIX-314.
-----------------------------------


Fix confirmed by user. Hence closing this issue now.

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned FELIX-314:
---------------------------------------

    Assignee: Felix Meschberger

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved FELIX-314.
-------------------------------------

    Resolution: Fixed

Applied the patch with one slight modification apart from reformating: I named the reference counter to m_references because m_users does not really sound good as a reference counter.

Fixed at Revision 551911.

Deployed a new snapshot to the Apache Snapshot Repository.

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-314:
------------------------------------

    Attachment: FELIX-314.diff

Patch trying to fix the EventDispatcher issue.

This patch turns all static fields and methods into instance fields and methods. As a consequence the EventDispatcher constructor will start a thread on each call, while the EventDispatcher.shutdown method will stop the thread and remove the local reference to it.

Incidentally, only two locations inside the Framework project are touched by this change: The Felix.shutdownInternalStart and Felix.start methods have to use the m_dispatcher field instead of calling the static method.

I do not know of any other users of the EventDispatcher class, but I assume, there aren't any outside the Framework.

If nobody opposes, I will apply this patch.

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509030 ] 

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

I am okay with those changes...if you format the code to look like the existing code[1], then I think it looks good to commit. What do you think, Karl?

[1] http://cwiki.apache.org/FELIX/codingstandards.html

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On Jun 29, 2007, at 3:11 AM, Felix Meschberger (JIRA) wrote:

>
>     [ https://issues.apache.org/jira/browse/FELIX-314? 
> page=com.atlassian.jira.plugin.system.issuetabpanels:comment- 
> tabpanel#action_12509034 ]
>
> Felix Meschberger commented on FELIX-314:
> -----------------------------------------
>
>> if you format the code to look like the existing code[1]
>
> Hmm, looks like the blanks are not there (anymore ?) in parentheses  
> of arguments, right ? But of course, will do that alignment. No  
> problem :-)

I think that was the main thing that I saw. :-)

-> richard

>
>> EventDispatcher class not reusable in same class loader for  
>> multiple Felix instances
>> --------------------------------------------------------------------- 
>> ---------------
>>
>>                 Key: FELIX-314
>>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>>             Project: Felix
>>          Issue Type: Bug
>>          Components: Framework
>>    Affects Versions: 0.8.0
>>            Reporter: Felix Meschberger
>>             Fix For: 1.0.0
>>
>>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>>
>>
>> Consider this use case:
>>    Felix felix = new Felix();
>>    felix.start(props, null);
>>    felix.shutdown();
>>    felix = new Felix();
>>    felix.start(props, null);
>>    felix.shutdown();
>> The first Felix instance will stop the EventDispatcher by calling  
>> the static EventDispatcher.shutdown() method thus stopping the  
>> event dispatcher thread and setting the static variables stopping  
>> and stopped to true. The reference to the event dispatcher thread  
>> in the static variable m_thread is not cleared on shutdown.
>> The second Felix instance will create an EventDispatcher instance  
>> but the static fields are not reset. That is the event dispatcher  
>> is assumed to be stopped and the event dispatcher thread will not  
>> be newly created and started.
>> I will suggest a patch for this issue.
>
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>


[jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509034 ] 

Felix Meschberger commented on FELIX-314:
-----------------------------------------

> if you format the code to look like the existing code[1]

Hmm, looks like the blanks are not there (anymore ?) in parentheses of arguments, right ? But of course, will do that alignment. No problem :-)

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12508935 ] 

Karl Pauls commented on FELIX-314:
----------------------------------

I'd like to stress how important it is to keep the number of framework created threads to a minimum. I have use cases where I need lots of frameworks and operating systems have thread limits which are often hard to change. Additionally, threads are cumbersome in resource restricted environments (and I'm using Felix there too). 

Furthermore, it looks to me like it should be enough to keep some kind of reference count of active frameworks in the EventDispatcher to make it work with a single thread, no?

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-314:
------------------------------------

    Attachment: FELIX-314_2.diff

Sounds reasonable. So I suggest the following solution: We make the constructor private and provide a static factory method to acquire an EventDispatcher instance. This factory method would care to have the thread running and the flags cleared as well as having the use counter managed. The shutdown method in turn is "fixed" to obey the reference counter and to drop the thread reference after stopping it.

I think it is more symetric to the static shutdown method if we have a static "startup" method instead of a constructor to acquire the EventDispatcher and setup the statics and a static shutdown to "disable" the dispatcher.

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12509040 ] 

Karl Pauls commented on FELIX-314:
----------------------------------

Looks good to me.

> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff, FELIX-314_2.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-314) EventDispatcher class not reusable in same class loader for multiple Felix instances

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12508831 ] 

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

I introduced that bug by apparently not thinking enough about what I was trying to do.

The reason for all of the statics was not accidental, the goal was to essentially require only one EventDispatcher (and thus one dispatcher thread) for all Felix instances inside of a given JVM (loaded by a specific class loader). The goal here was to reduce overhead.

I guess the debate here is whether or not it is worth it, but I would prefer such attempts to minimize thread usage. In truth, we probably should look at other places where threads are created to see if similar thread sharing can be achieved.


> EventDispatcher class not reusable in same class loader for multiple Felix instances
> ------------------------------------------------------------------------------------
>
>                 Key: FELIX-314
>                 URL: https://issues.apache.org/jira/browse/FELIX-314
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: 0.8.0
>            Reporter: Felix Meschberger
>             Fix For: 1.0.0
>
>         Attachments: FELIX-314.diff
>
>
> Consider this use case:
>    Felix felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
>    felix = new Felix();
>    felix.start(props, null);
>    felix.shutdown();
> The first Felix instance will stop the EventDispatcher by calling the static EventDispatcher.shutdown() method thus stopping the event dispatcher thread and setting the static variables stopping and stopped to true. The reference to the event dispatcher thread in the static variable m_thread is not cleared on shutdown.
> The second Felix instance will create an EventDispatcher instance but the static fields are not reset. That is the event dispatcher is assumed to be stopped and the event dispatcher thread will not be newly created and started.
> I will suggest a patch for this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.