quarkus-quartz
: programmatic scheduling of async tasks with jdbc-cmt
breaks application startup
#41361
Labels
Milestone
Describe the bug
I am using
quarkus-quartz
to schedule an asynchronous job programmatically usingio.quarkus.scheduler.Scheduler
and thejdbc-cmt
store type.After scheduling the job for the first time, when we restart the application it fails to create the
Scheduler
. The root cause is this:It looks like quarkus is incorrectly assuming that the scheduled job is synchronous, as it's casting it to a
Consumer
instead of aFunction
.Looking at the source code of
QuartzSchedulerImpl
, it seems this line is the problem: it should be usingEXECUTION_METADATA_ASYNC_TASK_CLASS
as key instead ofEXECUTION_METADATA_TASK_CLASS
.In fact, on this line it's attempting to load the async task class using the
EXECUTION_METADATA_ASYNC_TASK_CLASS
key.This seems to be the reason why quarkus is wrongly treating async tasks as synchronous when loading them from the database.
Expected behavior
The application should start without errors while an asynchronous job is scheduled in quartz's jdbc store.
Actual behavior
The application fails to start due to a
ClassCastException
:How to Reproduce?
Reproducer: https://github.com/jacopo-cavallarin/quarkus-quartz-bug-reproducer
Follow the README included in the reproducer.
Output of
uname -a
orver
Darwin M0-055116363 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64
Output of
java -version
openjdk version "22" 2024-03-19 OpenJDK Runtime Environment Temurin-22+36 (build 22+36) OpenJDK 64-Bit Server VM Temurin-22+36 (build 22+36, mixed mode)
Quarkus version or git rev
3.11.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.7 (8b094c9513efc1b9ce2d952b3b9c8eaedaf8cbf0) Maven home: /Users/jacopocavallarin/.m2/wrapper/dists/apache-maven-3.9.7-bin/33482774/apache-maven-3.9.7 Java version: 22, vendor: Eclipse Adoptium, runtime: /Users/jacopocavallarin/.sdkman/candidates/java/22-tem Default locale: en_IT, platform encoding: UTF-8 OS name: "mac os x", version: "14.5", arch: "aarch64", family: "mac"
Additional information
No response
The text was updated successfully, but these errors were encountered: