quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.82k stars 2.69k forks source link

Sporadic error in custom readiness check using `keycloak-admin-client`: `IllegalStateException: Client is closed` #38866

Closed famod closed 9 months ago

famod commented 9 months ago

Describe the bug

Using quarkus-keycloak-admin-client-reactive and quarkus-smallrye-health, we have a custom @Readiness check in an @ApplicationScoped bean that get's the request scoped instance injected. (In reality there is another @ApplicationScoped in between, but that shouldn't matter.) In the respective readiness check method that Keycloak instance is used to get the realm and count its users.

This works 99% of the time (and has worked 100% until a few weeks ago), but every now and then the check fails with:

java.lang.IllegalStateException: Client is closed
    at org.jboss.resteasy.reactive.client.impl.ClientImpl.abortIfClosed(ClientImpl.java:239)
    at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.abortIfClosed(WebTargetImpl.java:329)
    at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.resolveTemplate(WebTargetImpl.java:108)
    at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.resolveTemplate(WebTargetImpl.java:25)
    at org.keycloak.admin.client.resource.RealmsResource$$QuarkusRestClientInterface.realm(Unknown Source)
    at org.keycloak.admin.client.Keycloak.realm(Keycloak.java:146)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_ClientProxy.realm(Unknown Source)
    at ...

or

java.lang.IllegalStateException: Client is closed
    at io.vertx.core.http.impl.HttpClientImpl.checkClosed(HttpClientImpl.java:405)
    at io.vertx.core.http.impl.HttpClientImpl.doRequest(HttpClientImpl.java:281)
    at io.vertx.core.http.impl.HttpClientImpl.request(HttpClientImpl.java:184)
    at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler$5.lambda$apply$0(ClientSendRequestHandler.java:434)
    at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
    at org.jboss.resteasy.reactive.client.AsyncResultUni.subscribe(AsyncResultUni.java:31)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.performInnerSubscription(UniOnItemTransformToUni.java:81)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:57)
    at io.smallrye.mutiny.operators.uni.UniOnItemConsume$UniOnItemComsumeProcessor.onItem(UniOnItemConsume.java:43)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.forward(UniCreateFromKnownItem.java:38)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem.subscribe(UniCreateFromKnownItem.java:23)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform.subscribe(UniOnItemTransform.java:22)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemConsume.subscribe(UniOnItemConsume.java:30)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni.subscribe(UniOnItemTransformToUni.java:25)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:51)
    at io.smallrye.mutiny.groups.UniSubscribe.with(UniSubscribe.java:110)
    at io.smallrye.mutiny.groups.UniSubscribe.with(UniSubscribe.java:88)
    at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler.handle(ClientSendRequestHandler.java:94)
    at org.jboss.resteasy.reactive.client.handlers.ClientSendRequestHandler.handle(ClientSendRequestHandler.java:66)
    at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.invokeHandler(AbstractResteasyReactiveContext.java:231)
    at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
    at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.performRequestInternal(AsyncInvokerImpl.java:285)
    at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.performRequestInternal(AsyncInvokerImpl.java:275)
    at org.jboss.resteasy.reactive.client.impl.AsyncInvokerImpl.method(AsyncInvokerImpl.java:215)
    at org.jboss.resteasy.reactive.client.impl.InvocationBuilderImpl.method(InvocationBuilderImpl.java:324)
    at org.keycloak.admin.client.resource.UsersResourcecec060e01a4e8719a5229b25492913298e3846fc54.count(Unknown Source)
    at de.someproject.connector.keycloak.client.KeycloakUserApiClient.readinessCheck(KeycloakUserApiClient.java:40)
    at ...

As discussed in https://github.com/quarkusio/quarkus/discussions/38750, I changed this debug call to INFO and added the stacktrace which results in:

    at org.jboss.resteasy.reactive.client.impl.ClientImpl.close(ClientImpl.java:236)
    at org.keycloak.admin.client.Keycloak.close(Keycloak.java:177)
    at io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer.destroy(AutoCloseableDestroyer.java:15)
    at io.quarkus.keycloak.admin.client.common.AutoCloseableDestroyer.destroy(AutoCloseableDestroyer.java:9)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_Bean.doDestroy(Unknown Source)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_Bean.destroy(Unknown Source)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_Bean.destroy(Unknown Source)
    at io.quarkus.arc.impl.AbstractInstanceHandle.destroyInternal(AbstractInstanceHandle.java:78)
    at io.quarkus.arc.impl.ContextInstanceHandleImpl.destroy(ContextInstanceHandleImpl.java:26)
    at io.quarkus.arc.generator.Default_jakarta_enterprise_context_RequestScoped_ContextInstances.removeEach(Unknown Source)
    at io.quarkus.arc.impl.RequestContext.destroy(RequestContext.java:217)
    at io.quarkus.arc.impl.RequestContext.destroy(RequestContext.java:200)
    at io.quarkus.arc.ManagedContext.terminate(ManagedContext.java:50)
    at io.quarkus.smallrye.health.runtime.SmallRyeHealthHandlerBase.handle(SmallRyeHealthHandlerBase.java:37)
    at io.quarkus.smallrye.health.runtime.SmallRyeReadinessHandler.handle(SmallRyeReadinessHandler.java:8)
    at io.quarkus.smallrye.health.runtime.SmallRyeHealthHandlerBase.handle(SmallRyeHealthHandlerBase.java:23)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
    at io.vertx.ext.web.impl.RouterImpl.handleContext(RouterImpl.java:250)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:137)
    at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:62)
    at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$1.handle(HttpServerCommonHandlers.java:40)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:137)
    at io.quarkus.vertx.http.runtime.security.AbstractHttpAuthorizer.doPermissionCheck(AbstractHttpAuthorizer.java:119)
    at io.quarkus.vertx.http.runtime.security.AbstractHttpAuthorizer.checkPermission(AbstractHttpAuthorizer.java:93)
    at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.checkPermission(HttpAuthorizer.java:22)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$1.handle(HttpSecurityRecorder.java:68)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$1.handle(HttpSecurityRecorder.java:60)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:137)
    at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:339)
    at io.quarkus.resteasy.reactive.server.runtime.ResteasyReactiveRecorder$13.handle(ResteasyReactiveRecorder.java:332)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:137)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler$3$1.onItem(HttpSecurityRecorder.java:301)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler$3$1.onItem(HttpSecurityRecorder.java:291)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:60)
    at io.smallrye.mutiny.operators.uni.builders.DefaultUniEmitter.complete(DefaultUniEmitter.java:37)
    at io.smallrye.mutiny.groups.UniOnNull.lambda$failWith$1(UniOnNull.java:46)
    at io.smallrye.context.impl.wrappers.SlowContextualBiConsumer.accept(SlowContextualBiConsumer.java:21)
    at io.smallrye.mutiny.groups.UniOnItem.lambda$transformToUni$4(UniOnItem.java:177)
    at io.smallrye.context.impl.wrappers.SlowContextualConsumer.accept(SlowContextualConsumer.java:21)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateWithEmitter.subscribe(UniCreateWithEmitter.java:22)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.performInnerSubscription(UniOnItemTransformToUni.java:81)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:57)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.forward(UniCreateFromKnownItem.java:38)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem.subscribe(UniCreateFromKnownItem.java:23)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni.subscribe(UniOnItemTransformToUni.java:25)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:51)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler$3.onItem(HttpSecurityRecorder.java:291)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler$3.onItem(HttpSecurityRecorder.java:276)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.forwardTo(UniMemoizeOp.java:123)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.notifyAwaiters(UniMemoizeOp.java:135)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.onItem(UniMemoizeOp.java:97)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:60)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.forward(UniCreateFromKnownItem.java:38)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem.subscribe(UniCreateFromKnownItem.java:23)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.performInnerSubscription(UniOnItemTransformToUni.java:81)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:57)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform$UniOnItemTransformProcessor.onItem(UniOnItemTransform.java:43)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.forward(UniCreateFromKnownItem.java:38)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem.subscribe(UniCreateFromKnownItem.java:23)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform.subscribe(UniOnItemTransform.java:22)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransform.subscribe(UniOnItemTransform.java:22)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni.subscribe(UniOnItemTransformToUni.java:25)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:51)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.subscribe(UniMemoizeOp.java:59)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.groups.UniSubscribe.withSubscriber(UniSubscribe.java:51)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler.handle(HttpSecurityRecorder.java:276)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$AbstractAuthenticationHandler.handle(HttpSecurityRecorder.java:224)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1285)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:177)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:137)
    at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:68)
    at io.vertx.ext.web.impl.RouterImpl.handle(RouterImpl.java:37)
    at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$2.handle(HttpServerCommonHandlers.java:86)
    at io.quarkus.vertx.http.runtime.options.HttpServerCommonHandlers$2.handle(HttpServerCommonHandlers.java:69)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:147)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder$1.handle(VertxHttpRecorder.java:123)
    at io.vertx.core.impl.ContextImpl.emit(ContextImpl.java:335)
    at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:176)
    at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:174)
    at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:159)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:153)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.vertx.core.http.impl.Http1xUpgradeToH2CHandler.channelRead(Http1xUpgradeToH2CHandler.java:124)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61)
    at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Unknown Source)

Curiously, only in a few of my many test sessions (session meaning running a readiness loop on a cleanly started server), I got this error instead:

jakarta.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of SYNTHETIC bean [class=org.keycloak.admin.client.Keycloak, id=UWuGrtXQbAUeC9_5MBr5rdaRQ0Y]
    - you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
    at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:70)
    at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:30)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_ClientProxy.arc$delegate(Unknown Source)
    at org.keycloak.admin.client.Keycloak_UWuGrtXQbAUeC9_5MBr5rdaRQ0Y_Synthetic_ClientProxy.realm(Unknown Source)
    at de.someproject.idp.connector.keycloak.client.KeycloakUserApiClient.api(KeycloakUserApiClient.java:92)
    at de.someproject.idp.connector.keycloak.client.KeycloakUserApiClient.readinessCheck(KeycloakUserApiClient.java:40)
    at de.someproject.common.rest.client.RestClientWrapper$Interceptor.intercept(RestClientWrapper.java:50)
    at de.someproject.idp.connector.KeycloakIdpConnector.executeReadinessCheck(KeycloakIdpConnector.java:321)
    at de.someproject.common.healthcheck.ConnectorReadinessCheck.call(ConnectorReadinessCheck.java:64)
    at ...

So I went ahead and tried placing @ActivateRequestContext but failed to find the proper spot for this setup.

Expected behavior

Consistent results with no error jitter.

Actual behavior

Failing check every now even though Keycloak is alive and kicking.

How to Reproduce?

no reproducer for now

Output of uname -a or ver

No response

Output of java -version

17.0.10

Quarkus version or git rev

3.7.3

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

I ran my test sessions in a local docker compose setup but we also see it on our dev envs (also docker compose) and our Nomad envs - so I'd rule out network issues at this point.

See also discussion: https://github.com/quarkusio/quarkus/discussions/38750

quarkus-bot[bot] commented 9 months ago

/cc @pedroigor (keycloak), @sberyozkin (keycloak)

gsmet commented 9 months ago

Wondering if it could be related to https://github.com/quarkusio/quarkus/pull/37352 that landed in 3.7.0?

sberyozkin commented 9 months ago

Linking to #38605 just in case too, and CC-ing to Martin @mkouba

famod commented 9 months ago

Wondering if it could be related to #37352 that landed in 3.7.0?

Let me run a loop with 3.6.9...

famod commented 9 months ago

Wondering if it could be related to #37352 that landed in 3.7.0?

Let me run a loop with 3.6.9...

I was unable to reproduce in 3.6.9, now trying with 3.7.3 plus git revert da170cebc42...

famod commented 9 months ago

Wondering if it could be related to #37352 that landed in 3.7.0?

Let me run a loop with 3.6.9...

I was unable to reproduce in 3.6.9, now trying with 3.7.3 plus git revert da170cebc42...

Yeah that's it - spot on @gsmet!

geoand commented 9 months ago

cc @xstefank

xstefank commented 9 months ago

I was able to reproduce it, looking.

famod commented 9 months ago

Thanks @xstefank! Crossing my fingers the fix might make it before 3.7.4, if it hasn't sailed already that is.

gsmet commented 9 months ago

I wouldn't hold my breath as I will build it tomorrow morning (together with the 3.8.0 core artifacts). But it might land in 3.8.1 if not and 3.8 will be the continuation of the 3.7 branch (and a LTS) so it won't be a risky update.

xstefank commented 9 months ago

@Ladicek should open a PR soon :)

Ladicek commented 9 months ago

Submitted #38888, which seems to fix this issue.

gsmet commented 9 months ago

@famod if you have some cycles to test @Ladicek 's patch this afternoon, that would be nice.

gsmet commented 9 months ago

Ah, I see you are already on it :).

xstefank commented 9 months ago

We couldn't reproduce it anymore with the #38888