1515import java .util .HashSet ;
1616import java .util .List ;
1717import java .util .Map ;
18+ import java .util .Map .Entry ;
1819import java .util .Optional ;
1920import java .util .Set ;
2021import java .util .concurrent .CompletableFuture ;
@@ -176,6 +177,7 @@ void collectScheduledMethods(BeanArchiveIndexBuildItem beanArchives, BeanDiscove
176177 BuildProducer <ScheduledBusinessMethodItem > scheduledBusinessMethods ) {
177178
178179 // First collect static scheduled methods
180+ Map <MethodInfo , List <AnnotationInstance >> staticScheduledMethods = new HashMap <>();
179181 List <AnnotationInstance > schedules = new ArrayList <>(
180182 beanArchives .getIndex ().getAnnotations (SchedulerDotNames .SCHEDULED_NAME ));
181183 for (AnnotationInstance annotationInstance : beanArchives .getIndex ().getAnnotations (SchedulerDotNames .SCHEDULES_NAME )) {
@@ -198,13 +200,23 @@ void collectScheduledMethods(BeanArchiveIndexBuildItem beanArchives, BeanDiscove
198200 method .name (), declaringClass .name ()));
199201 }
200202 if (Modifier .isStatic (method .flags ()) && !KotlinUtil .isSuspendMethod (method )) {
201- scheduledBusinessMethods .produce (new ScheduledBusinessMethodItem (null , method , schedules ,
202- transformedAnnotations .hasAnnotation (method , SchedulerDotNames .NON_BLOCKING ),
203- transformedAnnotations .hasAnnotation (method , SchedulerDotNames .RUN_ON_VIRTUAL_THREAD )));
204- LOGGER .debugf ("Found scheduled static method %s declared on %s" , method , declaringClass .name ());
203+ List <AnnotationInstance > methodSchedules = staticScheduledMethods .get (method );
204+ if (methodSchedules == null ) {
205+ methodSchedules = new ArrayList <>();
206+ staticScheduledMethods .put (method , methodSchedules );
207+ }
208+ methodSchedules .add (annotationInstance );
205209 }
206210 }
207211
212+ for (Entry <MethodInfo , List <AnnotationInstance >> e : staticScheduledMethods .entrySet ()) {
213+ MethodInfo method = e .getKey ();
214+ scheduledBusinessMethods .produce (new ScheduledBusinessMethodItem (null , method , e .getValue (),
215+ transformedAnnotations .hasAnnotation (method , SchedulerDotNames .NON_BLOCKING ),
216+ transformedAnnotations .hasAnnotation (method , SchedulerDotNames .RUN_ON_VIRTUAL_THREAD )));
217+ LOGGER .debugf ("Found scheduled static method %s declared on %s" , method , method .declaringClass ().name ());
218+ }
219+
208220 // Then collect all business methods annotated with @Scheduled
209221 for (BeanInfo bean : beanDiscovery .beanStream ().classBeans ()) {
210222 collectScheduledMethods (beanArchives .getIndex (), transformedAnnotations , bean ,
0 commit comments