[cdi-dev] [JBoss JIRA] (CDI-501) Firing and consuming events should take place in the same thread
Mark Struberg (JIRA)
issues at jboss.org
Wed Feb 11 11:42:49 EST 2015
[ https://issues.jboss.org/browse/CDI-501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13039594#comment-13039594 ]
Mark Struberg commented on CDI-501:
-----------------------------------
I think it's implicitly defined as we say that we use standard CDI events for our own Extensions. And all the extension event processing heavily relies on the mutated event instance. So fire() really needs to wait. Could be made clearer though...
> 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 (discussion)
>
>
> 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.11#6341)
More information about the cdi-dev
mailing list