<font size=2 face="sans-serif">Hi Martin. <br>
<br>
My mistake. I thought the EventImpl was ignoring ExecutorServices#getTaskExecutor()
but after reading your email I checked again and found it later down the
stack, and upon further investigation the Executor we're providing doesn't
handle what I was told it would, which means it can be fixed. Thanks for
your help. <br>
<br>
P.S. The NPE is CDI.current() returning null, then a method is called on
that null. It's the result of some ThreadLocals not being set inside our
code.</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Martin Kouba &lt;mkouba@redhat.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">To: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Benjamin Confino &lt;BENJAMIC@uk.ibm.com&gt;,
weld-dev@lists.jboss.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">Tom Evans &lt;TEVANS@uk.ibm.com&gt;,
Emily Jiang &lt;EMIJIANG@uk.ibm.com&gt;</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date: &nbsp; &nbsp; &nbsp;
&nbsp;</font><font size=1 face="sans-serif">18/07/2018 08:18</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject: &nbsp; &nbsp;
&nbsp; &nbsp;</font><font size=1 face="sans-serif">Re: [weld-dev]
Should EventImpl.fireAsync use ExecutorServices from the ServiceRegistry</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>Hi Benjamin,<br>
<br>
If no Executor is provided - either fireAsync(U event) or no executor <br>
set to the notification options - Weld uses the Executor returned from
<br>
org.jboss.weld.manager.api.ExecutorServices#getTaskExecutor() or <br>
ForkJoinPool#commonPool() if no ExecutorServices is registered. In other
<br>
words, it's up to the integrator which Executor is used.<br>
<br>
And yes, Event#fireAsync(U, NotificationOptions) javadoc is outdated -
<br>
in the first versions it was only possible to pass an Executor.<br>
<br>
What does the NPE look like?<br>
<br>
Thanks,<br>
<br>
Martin<br>
<br>
Dne 17.7.2018 v 18:30 Benjamin Confino napsal(a):<br>
&gt; Hello<br>
&gt; <br>
&gt; I have a customer with the following<br>
&gt; <br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;@Inject<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Event&lt;Message&gt; event;<br>
&gt; <br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; @Resource<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ManagedExecutorService threadPool;<br>
&gt; <br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public void fireAsyncEvent() {<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; System.out.println(&quot;Sending Async-Message
via CDI&quot;);<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; event.fireAsync(new Message(&quot;Hello&quot;));<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; <br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; public void fireAsyncEvent_2() {<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; event.fireAsync(new Message(&quot;Hello&quot;),
<br>
&gt; NotificationOptions.ofExecutor(threadPool));<br>
&gt; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; <br>
&gt; fireAsyncEvent() eventually results in an NPE when a JSF class attempts
<br>
&gt; tries to call CDI.current() fireAsyncEvent_2() works correctly. I
was <br>
&gt; hoping that it would be possible to fix fireAsyncEvent to remove the
<br>
&gt; dependency on passing in an executor service every time it is used.<br>
&gt; <br>
&gt; We currently set an executor service into the weld service registry,
and <br>
&gt; I was wondering if org.jboss.weld.event.EventImpl fetch the &nbsp;executor
<br>
&gt; service from the service registry. Either only when fireAsync is called
<br>
&gt; without any NotificationOptions, or perhaps more aggressively and
set <br>
&gt; the default executor service if NotificationOptions are provided but
do <br>
&gt; not explicitly contain an executor service (The javadoc is unclear,
but <br>
&gt; I believe calling ofExecutor() provides this functionality).<br>
&gt; <br>
&gt; Before going further with this I wanted to ask for a quick sanity
check. <br>
&gt; Is this fix plausible?<br>
&gt; <br>
&gt; Regards<br>
&gt; Benjamin<br>
&gt; Unless stated otherwise above:<br>
&gt; IBM United Kingdom Limited - Registered in England and Wales with
number <br>
&gt; 741598.<br>
&gt; Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU<br>
&gt; <br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; weld-dev mailing list<br>
&gt; weld-dev@lists.jboss.org<br>
&gt; </font></tt><a href="https://lists.jboss.org/mailman/listinfo/weld-dev"><tt><font size=2>https://lists.jboss.org/mailman/listinfo/weld-dev</font></tt></a><tt><font size=2><br>
&gt; <br>
<br>
-- <br>
Martin Kouba<br>
Senior Software Engineer<br>
Red Hat, Czech Republic<br>
<br>
</font></tt>
<br>
<br><font size=2 face="sans-serif"><br>
Unless stated otherwise above:<br>
IBM United Kingdom Limited - Registered in England and Wales with number
741598. <br>
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU<br>
</font>