José Paumard created CDI-501:
--------------------------------
Summary: 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
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)