<div dir="ltr">There&#39;s defnitely a bug in the spec on that point, because nowhere it is stated that the event are consumed in the same thread as the one that fired the event. So, the spec allows for mutable event payload and does not state that this event should be consumed in the same thread. It is thus possible to have concurrency (incl. but not limited to visibility) issues. <div><br></div><div>While introducing async events, we definitely need to do some clean up here. And be careful about not breaking existing code, of course. </div><div><br></div><div>José</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-17 17:53 GMT+01:00 Peter Muir <span dir="ltr">&lt;<a href="mailto:pmuir@redhat.com" target="_blank">pmuir@redhat.com</a>&gt;</span>:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
----- Original Message -----<br>
&gt; Ok guys,<br>
&gt;<br>
&gt; Let’s do it again. I didn’t say we have to forbid the mutability I said we<br>
&gt; have at least to explicitly write that it’s mutable and seriously think of<br>
&gt; having it immutable for event fired asynchronously.<br>
&gt;<br>
&gt; &gt; (Pete) I don’t think it’s specified. As objects are, by default in Java,<br>
&gt; &gt; mutable, I would assume that payloads are implicitly mutable.<br>
&gt;<br>
&gt;<br>
&gt; Sorry @Pete I don’t agree with your point. Yes, in Java object are mutable<br>
&gt; but firing an event is not a standard Java feature : you send your object to<br>
&gt; a black box and let this box dispatch your object to listeners transforming<br>
&gt; one call to multiple call : it’s far from standard Java rules. Even if it’s<br>
&gt; not written it’s an observer pattern and there are people out there thinking<br>
&gt; that introducing mutability in observer is an anti-pattern since some<br>
&gt; listener will receive a different payload than the one that was sent to<br>
&gt; them.<br>
<br>
</span>I agree it should be tidied up. I&#39;m simply stating that currently I would interpret the spec as allowing mutable payloads.<br>
<span class="im HOEnZb"><br>
&gt; It’s like making a method call and having no guarantee that the parameter<br>
&gt; received in the callee has the same value that in the caller...<br>
&gt; I won’t start discussion on bad practice or anti pattern  as I also use<br>
&gt; mutability in event but there as much reason for user to assume their<br>
&gt; payload will be mutable than the other way around.<br>
&gt; I can assure you that when I give a talk on CDI, this payload mutability is<br>
&gt; often a surprise for attendees...<br>
&gt;<br>
&gt; &gt; (Romain) why isn&#39;t it portable?<br>
&gt;<br>
&gt;<br>
&gt; So yes @Romain it’s not portable (in theory of course, since both<br>
&gt; implementations support mutability). Someone could write a CDI<br>
&gt; implementation with event payload immutability without any issue with the<br>
&gt; spec and TCK.<br>
&gt;<br>
&gt; Most of you are so dependent of this feature that you only reacted to the<br>
&gt; idea or forbidding it (which wasn’t the content of my mail) ;). So we all<br>
&gt; agree that it’s an important feature. Therefore what’s the issue to specify<br>
&gt; this mutability and add TCK test for it ?<br>
&gt;<br>
&gt; Now I don’t deal with that subject for nothing, we are planning to introduce<br>
&gt; Async events. I think that it’ll bring extra complexity if we support<br>
&gt; mutability in async events. And even if I’m wrong and we finally go for<br>
&gt; mutability in async events, this will lead to possible side effect (lock)<br>
&gt; that could have impact on perf, so it should be explicitly written IMO.<br>
&gt;<br>
&gt; Antoine<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
</span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.</div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div><a href="http://blog.paumard.org" target="_blank">Java le soir</a> <a href="http://blog.paumard.org/cours-tutoriaux/" target="_blank">Cours Java en ligne</a></div><div><a href="http://twitter.com/#!/JosePaumard" target="_blank">Twitter</a> <a href="http://www.parisjug.org" target="_blank">Paris JUG</a> <a href="http://www.devoxx.fr" target="_blank">Devoxx France</a></div><div>M : +33 6 76 82 91 47</div></div>
</div>