[cdi-dev] [JBoss JIRA] (CDI-501) Firing and consuming events should take place in the same thread

Antoine Sabot-Durand (JIRA) issues at jboss.org
Fri Jun 12 07:51:02 EDT 2015


     [ https://issues.jboss.org/browse/CDI-501?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antoine Sabot-Durand updated CDI-501:
-------------------------------------
    Fix Version/s: 2.0-EDR1
                       (was: 2.0 (discussion))


> Firing and consuming events should take place in the same thread
> ----------------------------------------------------------------
>
>                 Key: CDI-501
>                 URL: https://issues.jboss.org/browse/CDI-501
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Events
>    Affects Versions: 1.2.Final
>            Reporter: José Paumard
>             Fix For: 2.0-EDR1
>
>
> An event can be fired with a call to event.fireEvent(payload). CDI then calls all the observers for that event with the given payload. 
> All the implementations call the annotated methods of the observers in the same thread as the one where the call to fireEvent() was made. In some cases the payload object is mutable, and the observers leverage that property to change its state.
> The issue is the following : 
> - the payload object is not specified, it can then be mutable, non-synchronized etc...
> - it is not stated that the firing of the event and the consuming of the payload should occur in the same thread. 
> So one could build an implementation where the consuming of the event occurs in different threads than the one where the fireEvent() was called. If the payload is mutated in the observer methods then visibility issues due to race conditions can arise. 
> Side note : most of the time it is also assumed that the fireEvent() method returns when all the observers have been called and returned. This point is not specified. We can assume that other issues could arise when it is not the case. 



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)



More information about the cdi-dev mailing list