Skip to content

Commit

Permalink
force TimerService to run the handler in alignment with the beginni…
Browse files Browse the repository at this point in the history
…ng of the second (Consensys#6302)

* force TimerService to run the handler in alignment with the beginning of the second

* remove delay at startup

* remove delay at startup
  • Loading branch information
tbenr authored Oct 6, 2022
1 parent 61f5789 commit ce5d3e7
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import static org.quartz.SimpleScheduleBuilder.simpleSchedule;
import static org.quartz.TriggerBuilder.newTrigger;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import org.quartz.JobDetail;
Expand Down Expand Up @@ -85,6 +88,7 @@ public SafeFuture<?> doStart() {
// contention), then just skip it and fire the next event when it is due
.withMisfireHandlingInstructionNextWithRemainingCount()
.repeatForever())
.startAt(Date.from(Instant.now().truncatedTo(ChronoUnit.SECONDS)))
.build();
sched.scheduleJob(job, trigger);
sched.start();
Expand Down

0 comments on commit ce5d3e7

Please sign in to comment.