]
Marek Kopecký commented on WFLY-11907:
--------------------------------------
This issue can be reproduced also by this two classes and curl:
{code:java}
@Path("/")
public class Resource {
@Inject
private Event<String> resteasyClientEvent;
@GET
@Path("/sync")
public void sync() {
;
}
}
@RequestScoped
public class ResteasyClientEventObserver {
static final Logger log =
Logger.getLogger(ResteasyClientEventObserver.class.toString());
public void observeSync(@Observes String event) {
load(event);
}
public void observeAsync(@ObservesAsync String event) {
load(event);
}
private void load(String event) {
try {
Client client = ResteasyClientBuilder.newBuilder().build();
Response response = client.target(event).request().get();
log.info(String.format("Received a %s response from %s",
response.getStatus(), event));
} catch (Exception e) {
e.printStackTrace();
}
}
}
{code}
{noformat}
curl -v
{noformat}
This issue is valid on WF14 and WF master. This issue is on fireAsync CDI feature. This
feature was introduced on CDI 2.0. WF11 uses CDI 1.2, so this is not a regression against
WF11.
NPE trying to use Resteasy Client inside CDI Async Event
--------------------------------------------------------
Key: WFLY-11907
URL:
https://issues.jboss.org/browse/WFLY-11907
Project: WildFly
Issue Type: Bug
Components: CDI / Weld, REST
Affects Versions: 16.0.0.Final
Environment: Java 8
Wildfly 16
Reporter: Cody Lerum
Assignee: Matej Novotny
Priority: Major
When attempting to use the Resteasy Client inside a CDI Async Event a NPE is thrown.
{code}
12:49:33,513 ERROR [stderr] (Weld Thread Pool -- 4) java.lang.RuntimeException:
java.lang.NullPointerException
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:49)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.getProviderFactory(ResteasyClientBuilder.java:362)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:395)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:38)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
com.outjected.demo.ResteasyClientEventObserver.load(ResteasyClientEventObserver.java:28)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
com.outjected.demo.ResteasyClientEventObserver.observeAsync(ResteasyClientEventObserver.java:23)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:49:33,514 ERROR [stderr] (Weld Thread Pool -- 4) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
java.lang.reflect.Method.invoke(Method.java:498)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.injection.MethodInvocationStrategy$DefaultMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:109)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
javax.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:124)
12:49:33,515 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.util.Observers.notify(Observers.java:166)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverNotifier.notifyAsyncObserver(ObserverNotifier.java:413)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverNotifier.lambda$notifyAsyncObservers$5(ObserverNotifier.java:356)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverNotifier.lambda$null$8(ObserverNotifier.java:438)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.security.spi.SecurityServices.lambda$getSecurityContextAssociator$0(SecurityServices.java:80)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.weld.event.ObserverNotifier.lambda$createSupplier$9(ObserverNotifier.java:435)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
java.util.concurrent.CompletableFuture$AsyncSupply.run$$$capture(CompletableFuture.java:1590)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
12:49:33,516 ERROR [stderr] (Weld Thread Pool -- 4) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) at
java.lang.Thread.run(Thread.java:748)
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.threads.JBossThread.run(JBossThread.java:485)
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) Caused by:
java.lang.NullPointerException
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:60)
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) at
org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:45)
12:49:33,517 ERROR [stderr] (Weld Thread Pool -- 4) ... 28 more
{code}