-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scheduler - scheduled methods are not inherited
- this is a breaking change - however, the current behavior is undocumented and inconsistent; e.g. if Scheduled#identity() is used then the build always fails - also the scope annotation is not added automatically to a subclass of a class that declares a Scheduled annotation, i.e. the class would be ignored and would result in runtime error - resolves #24212
- Loading branch information
Showing
3 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../src/test/java/io/quarkus/scheduler/test/inheritance/ScheduledMethodNotInheritedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.quarkus.scheduler.test.inheritance; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.scheduler.Scheduled; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class ScheduledMethodNotInheritedTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(Jobs.class, MyJobs.class)); | ||
|
||
@Test | ||
public void testExecution() throws InterruptedException { | ||
assertTrue(Jobs.LATCH.await(5, TimeUnit.SECONDS)); | ||
assertTrue(Jobs.JOB_CLASSES.stream().allMatch(s -> s.equals(Jobs.class.getName()))); | ||
} | ||
|
||
@Singleton | ||
static class MyJobs extends Jobs { | ||
|
||
} | ||
|
||
static class Jobs { | ||
|
||
static final CountDownLatch LATCH = new CountDownLatch(2); | ||
static final List<String> JOB_CLASSES = new CopyOnWriteArrayList<>(); | ||
|
||
@Scheduled(every = "1s", identity = "foo") | ||
void everySecond() { | ||
JOB_CLASSES.add(getClass().getName()); | ||
LATCH.countDown(); | ||
} | ||
} | ||
} |