<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:
</font><font size=1 face="sans-serif">Martin Kouba <mkouba@redhat.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Benjamin Confino <BENJAMIC@uk.ibm.com>,
weld-dev@lists.jboss.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">Tom Evans <TEVANS@uk.ibm.com>,
Emily Jiang <EMIJIANG@uk.ibm.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">18/07/2018 08:18</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</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>
> Hello<br>
> <br>
> I have a customer with the following<br>
> <br>
> @Inject<br>
> Event<Message> event;<br>
> <br>
> @Resource<br>
> ManagedExecutorService threadPool;<br>
> <br>
> public void fireAsyncEvent() {<br>
> System.out.println("Sending Async-Message
via CDI");<br>
> event.fireAsync(new Message("Hello"));<br>
> }<br>
> <br>
> public void fireAsyncEvent_2() {<br>
> event.fireAsync(new Message("Hello"),
<br>
> NotificationOptions.ofExecutor(threadPool));<br>
> }<br>
> <br>
> fireAsyncEvent() eventually results in an NPE when a JSF class attempts
<br>
> tries to call CDI.current() fireAsyncEvent_2() works correctly. I
was <br>
> hoping that it would be possible to fix fireAsyncEvent to remove the
<br>
> dependency on passing in an executor service every time it is used.<br>
> <br>
> We currently set an executor service into the weld service registry,
and <br>
> I was wondering if org.jboss.weld.event.EventImpl fetch the executor
<br>
> service from the service registry. Either only when fireAsync is called
<br>
> without any NotificationOptions, or perhaps more aggressively and
set <br>
> the default executor service if NotificationOptions are provided but
do <br>
> not explicitly contain an executor service (The javadoc is unclear,
but <br>
> I believe calling ofExecutor() provides this functionality).<br>
> <br>
> Before going further with this I wanted to ask for a quick sanity
check. <br>
> Is this fix plausible?<br>
> <br>
> Regards<br>
> Benjamin<br>
> Unless stated otherwise above:<br>
> IBM United Kingdom Limited - Registered in England and Wales with
number <br>
> 741598.<br>
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
PO6 3AU<br>
> <br>
> <br>
> _______________________________________________<br>
> weld-dev mailing list<br>
> weld-dev@lists.jboss.org<br>
> </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>
> <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>