[jboss-jira] [JBoss JIRA] (WFLY-12811) Can not inject MP Config property to a HealthCheck bean

Jeff Mesnil (Jira) issues at jboss.org
Fri Nov 22 11:45:00 EST 2019


    [ https://issues.jboss.org/browse/WFLY-12811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13816801#comment-13816801 ] 

Jeff Mesnil edited comment on WFLY-12811 at 11/22/19 11:44 AM:
---------------------------------------------------------------

I built your reproducer and it works as expected:

[code]
$ ./bin/standalone.sh -c standalone-full.xml -Ddummy_live=true
...
$ curl  http://:8080/mp-1.0/dummy
true
$ curl  http://:9990/health
{"status":"UP","checks":[{"name":"dummy","status":"UP"}]}

$ ./bin/standalone.sh -c standalone-full.xml -Ddummy_live=false
...
$ curl  http://:8080/mp-1.0/dummy
false
$ curl  http://:9990/health
{"status":"DOWN","checks":[{"name":"dummy","status":"DOWN"}]}
[code]



was (Author: jmesnil):
I built your reproducer and it works as expected:

{code}
$ ./bin/standalone.sh -c standalone-full.xml -Ddummy_live=true
...
$ curl  http://:8080/mp-1.0/dummy
true
$ curl  http://:9990/health
{"status":"UP","checks":[{"name":"dummy","status":"UP"}]}

$ ./bin/standalone.sh -c standalone-full.xml -Ddummy_live=false
...
$ curl  http://:8080/mp-1.0/dummy
false
$ curl  http://:9990/health
{"status":"DOWN","checks":[{"name":"dummy","status":"DOWN"}]}

> Can not inject MP Config property to a HealthCheck bean
> -------------------------------------------------------
>
>                 Key: WFLY-12811
>                 URL: https://issues.jboss.org/browse/WFLY-12811
>             Project: WildFly
>          Issue Type: Bug
>          Components: CDI / Weld, MP Health
>    Affects Versions: 18.0.1.Final
>            Reporter: Ivan Straka
>            Assignee: Jeff Mesnil
>            Priority: Critical
>         Attachments: mp-1.0.war
>
>
> I am playing a bit with MP specs (getting multiple specs to work together). I have been trying to return Health status based on injected config property (MP Config). However it looks like the property is not properly injected to the bean.
> {code:java}
> @Liveness
> @ApplicationScoped
> public class CDIBasedLivenessHealthCheck implements HealthCheck {
>     @Inject
>     @ConfigProperty(name = "dummy_live")
>     private Provider<Boolean> live;
>     @Override
>     public HealthCheckResponse call() {
>         return HealthCheckResponse.named("dummy")
>                 .state(live.get())
>                 .build();
>     }
> }
> {code}
> I am get following error:
> {code:java}
> 15:41:04,616 ERROR [org.wildfly.extension.microprofile.health.smallrye] (management I/O-2) Error processing Health Checks: java.lang.NullPointerException
> 	at health.CDIBasedLivenessHealthCheck.call(CDIBasedLivenessHealthCheck.java:26)
> 	at health.CDIBasedLivenessHealthCheck$Proxy$_$$_WeldClientProxy.call(Unknown Source)
> 	at org.wildfly.extension.microprofile.health.HealthReporter.jsonObject(HealthReporter.java:120)
> 	at org.wildfly.extension.microprofile.health.HealthReporter.fillCheck(HealthReporter.java:107)
> 	at org.wildfly.extension.microprofile.health.HealthReporter.processChecks(HealthReporter.java:96)
> 	at org.wildfly.extension.microprofile.health.HealthReporter.getHealth(HealthReporter.java:79)
> 	at org.wildfly.extension.microprofile.health.HealthReporter.getHealth(HealthReporter.java:60)
> 	at org.wildfly.extension.microprofile.health.HealthContextService$HealthCheckHandler.handleRequest(HealthContextService.java:100)
> 	at org.jboss.as.domain.http.server.security.RealmReadinessHandler.handleRequest(RealmReadinessHandler.java:51)
> 	at org.jboss.as.domain.http.server.security.ServerErrorReadinessHandler.handleRequest(ServerErrorReadinessHandler.java:35)
> 	at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:91)
> 	at io.undertow.server.handlers.ChannelUpgradeHandler.handleRequest(ChannelUpgradeHandler.java:211)
> 	at io.undertow.server.handlers.cache.CacheHandler.handleRequest(CacheHandler.java:92)
> 	at io.undertow.server.handlers.error.SimpleErrorPageHandler.handleRequest(SimpleErrorPageHandler.java:78)
> 	at io.undertow.server.handlers.CanonicalPathHandler.handleRequest(CanonicalPathHandler.java:49)
> 	at org.jboss.as.domain.http.server.ManagementHttpRequestHandler.handleRequest(ManagementHttpRequestHandler.java:57)
> 	at org.jboss.as.domain.http.server.cors.CorsHttpHandler.handleRequest(CorsHttpHandler.java:75)
> 	at org.jboss.as.domain.http.server.ManagementHttpServer$UpgradeFixHandler.handleRequest(ManagementHttpServer.java:672)
> 	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:376)
> 	at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:255)
> 	at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
> 	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
> 	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
> 	at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
> 	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
> 	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
> 	at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
> 	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
> 	at org.xnio.nio.QueuedNioTcpServer2.acceptTask(QueuedNioTcpServer2.java:178)
> 	at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
> 	at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)
> {code}
> I believe there is a bug in MP Health integration rather than in weld. After checks are registered here in [CDIExtension|https://github.com/wildfly/wildfly/blob/master/microprofile/health-smallrye/src/main/java/org/wildfly/extension/microprofile/health/deployment/CDIExtension.java#L93] I am able to call _check.call()_ and I get _UP_ as a result. However during HTTP call here in [HealthReporter|https://github.com/wildfly/wildfly/blob/master/microprofile/health-smallrye/src/main/java/org/wildfly/extension/microprofile/health/HealthReporter.java#L73] I get NPE.
> I can inject a dummy bean. However if the dummy bean injects a config property, NPE is thrown. 



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list