logging and a catastrophic try/catch (no situations have called for this yet, but its worth testing for)

This commit is contained in:
jrandom
2004-05-12 07:47:22 +00:00
committed by zzz
parent 406048f7b9
commit 61f6871cd1

View File

@ -47,18 +47,22 @@ public class Timestamper implements Runnable {
public void run() { public void run() {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Starting up timestamper"); _log.info("Starting up timestamper");
while (true) { try {
if (_log.shouldLog(Log.DEBUG)) while (true) {
_log.debug("Querying servers " + _serverList);
long now = NtpClient.currentTime(_serverList);
if (now < 0) {
_log.error("Unable to contact any of the NTP servers - network disconnect?");
} else {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Stamp time"); _log.debug("Querying servers " + _serverList);
stampTime(now); long now = NtpClient.currentTime(_serverList);
if (now < 0) {
_log.error("Unable to contact any of the NTP servers - network disconnect?");
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Stamp time");
stampTime(now);
}
try { Thread.sleep(DELAY_MS); } catch (InterruptedException ie) {}
} }
try { Thread.sleep(DELAY_MS); } catch (InterruptedException ie) {} } catch (Throwable t) {
_log.log(Log.CRIT, "Timestamper died!", t);
} }
} }
@ -67,7 +71,10 @@ public class Timestamper implements Runnable {
*/ */
private void stampTime(long now) { private void stampTime(long now) {
try { try {
URL url = new URL(_targetURL + "&now=" + getNow(now)); String toRequest = _targetURL + "&now=" + getNow(now);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Stamping [" + toRequest + "]");
URL url = new URL(toRequest);
Object o = url.getContent(); Object o = url.getContent();
// ignore the content // ignore the content
} catch (MalformedURLException mue) { } catch (MalformedURLException mue) {