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