smallrye / smallrye-health

Home Page:https://smallrye.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArrayIndexOutOfBoundsException at Quarkus application startup

gwenneg opened this issue · comments

One of our apps depends on Quarkus 2.8.3.Final which itself depends on smallrye-health 3.2.1.

On rare occasions, smallrye-health will throw the following exception at application startup:

2022-05-18 15:00:26,157 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-0) HTTP Request to /health/ready failed, error id: f942f79e-c71a-45f1-bc45-3c020ff40c01-1: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 0
	at java.base/java.util.ArrayList.add(ArrayList.java:487)
	at java.base/java.util.ArrayList.add(ArrayList.java:499)
	at io.smallrye.health.SmallRyeHealthReporter.initUnis(SmallRyeHealthReporter.java:189)
	at io.smallrye.health.SmallRyeHealthReporter.initChecks(SmallRyeHealthReporter.java:178)
	at io.smallrye.health.SmallRyeHealthReporter.getHealthAsync(SmallRyeHealthReporter.java:373)
	at io.smallrye.health.SmallRyeHealthReporter.getReadinessAsync(SmallRyeHealthReporter.java:259)
	at io.smallrye.health.SmallRyeHealthReporter.getReadiness(SmallRyeHealthReporter.java:225)
	at io.smallrye.health.SmallRyeHealthReporter_ClientProxy.getReadiness(Unknown Source)
	at io.quarkus.smallrye.health.runtime.SmallRyeReadinessHandler.getHealth(SmallRyeReadinessHandler.java:11)
	at io.quarkus.smallrye.health.runtime.SmallRyeHealthHandlerBase.doHandle(SmallRyeHealthHandlerBase.java:44)
	at io.quarkus.smallrye.health.runtime.SmallRyeHealthHandlerBase.handle(SmallRyeHealthHandlerBase.java:31)
	at io.quarkus.smallrye.health.runtime.SmallRyeReadinessHandler.handle(SmallRyeReadinessHandler.java:7)
	at io.quarkus.smallrye.health.runtime.SmallRyeHealthHandlerBase.handle(SmallRyeHealthHandlerBase.java:19)
	at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:548)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

This may be caused by a concurrent access to the same list from multiple threads and that list may not be thread-safe. I didn't check the code in details so my asumption may be wrong 😄

Thanks @gwenneg. By any chance, would be able to reproduce this on purpose? I can make the collections thread-safe but it would be good to know that it will fix the problem.

Sorry @xstefank, I've been really busy lately and I forgot to answer your last comment.

I see that you merged a fix. Thank you very much!

No worries @gwenneg. Please reopen this once this is merged in Quarkus and you'll still run into the issue.