Defensive access to volatile ScheduledFuture field
Includes defensive test arrangement for isInThePast() with at least 1 ms having passed. See gh-24560
This commit is contained in:
@@ -24,7 +24,9 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
|
||||
/**
|
||||
* Tests for {@link Task}.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 6.2
|
||||
*/
|
||||
class TaskTests {
|
||||
|
||||
@@ -77,20 +79,32 @@ class TaskTests {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
this.hasRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class FailingTestRunnable implements Runnable {
|
||||
|
||||
boolean hasRun;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
this.hasRun = true;
|
||||
throw new IllegalStateException("test exception");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user