X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FTimedRunnable.java;h=c58d6f90f3e4992700654b771a5676c6e6a363e6;hb=c9943f5bc72d4cde9356d3bd4cf73d36f4b2f754;hp=933b134341ae6502c59074d75c27f1a9f275d6dc;hpb=5ed99696d261c5359b2e036acfd2aef864f04a7e;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java index 933b134341..c58d6f90f3 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/TimedRunnable.java @@ -14,6 +14,7 @@ import scala.concurrent.duration.FiniteDuration; /** * An abstract class that implements a Runnable operation with a timer such that if the run method isn't * invoked within a timeout period, the operation is cancelled via {@link #doCancel}. + * *

* Note: this class is not thread safe and is intended for use only within the context of the same * actor that's passed on construction. The run method must be called on this actor's thread dispatcher as it @@ -28,17 +29,13 @@ abstract class TimedRunnable implements Runnable { TimedRunnable(FiniteDuration timeout, RaftActor actor) { Preconditions.checkNotNull(timeout); Preconditions.checkNotNull(actor); - cancelTimer = actor.getContext().system().scheduler().scheduleOnce(timeout, actor.self(), new Runnable() { - @Override - public void run() { - cancel(); - } - }, actor.getContext().system().dispatcher(), actor.self()); + cancelTimer = actor.getContext().system().scheduler().scheduleOnce(timeout, actor.self(), + (Runnable) () -> cancel(), actor.getContext().system().dispatcher(), actor.self()); } @Override public void run() { - if(canRun) { + if (canRun) { canRun = false; cancelTimer.cancel(); doRun();