|
12 | 12 | import java.time.ZoneId;
|
13 | 13 | import java.util.ArrayList;
|
14 | 14 | import java.util.HashMap;
|
| 15 | +import java.util.HashSet; |
15 | 16 | import java.util.List;
|
16 | 17 | import java.util.Map;
|
17 | 18 | import java.util.Optional;
|
| 19 | +import java.util.Set; |
18 | 20 | import java.util.concurrent.CompletableFuture;
|
19 | 21 | import java.util.concurrent.CompletionStage;
|
20 | 22 | import java.util.function.Function;
|
@@ -192,17 +194,23 @@ void validateScheduledBusinessMethods(SchedulerConfig config, List<ScheduledBusi
|
192 | 194 | ValidationPhaseBuildItem validationPhase, BuildProducer<ValidationErrorBuildItem> validationErrors) {
|
193 | 195 | List<Throwable> errors = new ArrayList<>();
|
194 | 196 | Map<String, AnnotationInstance> encounteredIdentities = new HashMap<>();
|
| 197 | + Set<String> methodDescriptions = new HashSet<>(); |
195 | 198 |
|
196 | 199 | for (ScheduledBusinessMethodItem scheduledMethod : scheduledMethods) {
|
| 200 | + if (!methodDescriptions.add(scheduledMethod.getMethodDescription())) { |
| 201 | + errors.add(new IllegalStateException("Multiple @Scheduled methods of the same name declared on the same class: " |
| 202 | + + scheduledMethod.getMethodDescription())); |
| 203 | + continue; |
| 204 | + } |
197 | 205 | MethodInfo method = scheduledMethod.getMethod();
|
198 | 206 | if (Modifier.isAbstract(method.flags())) {
|
199 | 207 | errors.add(new IllegalStateException("@Scheduled method must not be abstract: "
|
200 |
| - + method.declaringClass().name() + "#" + method.name() + "()")); |
| 208 | + + scheduledMethod.getMethodDescription())); |
201 | 209 | continue;
|
202 | 210 | }
|
203 | 211 | if (Modifier.isPrivate(method.flags())) {
|
204 | 212 | errors.add(new IllegalStateException("@Scheduled method must not be private: "
|
205 |
| - + method.declaringClass().name() + "#" + method.name() + "()")); |
| 213 | + + scheduledMethod.getMethodDescription())); |
206 | 214 | continue;
|
207 | 215 | }
|
208 | 216 |
|
|
0 commit comments