Hello

I have a customer with the following

       @Inject

        Event<Message> event;

        @Resource
        ManagedExecutorService threadPool;

       public void fireAsyncEvent() {

                System.out.println("Sending Async-Message via CDI");
                event.fireAsync(new Message("Hello"));
        }

        public void fireAsyncEvent_2() {
                event.fireAsync(new Message("Hello"), NotificationOptions.ofExecutor(threadPool));
        }

fireAsyncEvent() eventually results in an NPE when a JSF class attempts tries to call CDI.current() fireAsyncEvent_2() works correctly. I was hoping that it would be possible to fix fireAsyncEvent to remove the dependency on passing in an executor service every time it is used.

We currently set an executor service into the weld service registry, and I was wondering if org.jboss.weld.event.EventImpl fetch the  executor service from the service registry. Either only when fireAsync is called without any NotificationOptions, or perhaps more aggressively and set the default executor service if NotificationOptions are provided but do not explicitly contain an executor service (The javadoc is unclear, but I believe calling ofExecutor() provides this functionality).

Before going further with this I wanted to ask for a quick sanity check. Is this fix plausible?

Regards
Benjamin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU