Added braces and log message to HeartBeater

This commit is contained in:
hierynomus
2015-01-16 10:33:25 +01:00
parent 703a0df09d
commit a7872b394b

View File

@@ -36,8 +36,9 @@ final class Heartbeater
synchronized void setInterval(int interval) { synchronized void setInterval(int interval) {
this.interval = interval; this.interval = interval;
if (interval > 0 && getState() == Thread.State.NEW) if (interval > 0 && getState() == Thread.State.NEW) {
start(); start();
}
notify(); notify();
} }
@@ -47,14 +48,15 @@ final class Heartbeater
synchronized private int getPositiveInterval() synchronized private int getPositiveInterval()
throws InterruptedException { throws InterruptedException {
while (interval <= 0) while (interval <= 0) {
wait(); wait();
}
return interval; return interval;
} }
@Override @Override
public void run() { public void run() {
log.debug("Starting"); log.debug("Starting Heartbeat, sending heartbeat every {} seconds", interval);
try { try {
while (!isInterrupted()) { while (!isInterrupted()) {
final int hi = getPositiveInterval(); final int hi = getPositiveInterval();
@@ -67,11 +69,12 @@ final class Heartbeater
} catch (Exception e) { } catch (Exception e) {
if (isInterrupted()) { if (isInterrupted()) {
// We are meant to shut up and draw to a close if interrupted // We are meant to shut up and draw to a close if interrupted
} else } else {
trans.die(e); trans.die(e);
}
} }
log.debug("Stopping"); log.debug("Stopping Heartbeat");
} }
} }