From b5e043025fb0aeef5e150d433cb0808b66441efd Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Thu, 7 Apr 2005 17:07:33 +0000 Subject: [PATCH] looking@why my junit reports are apparently an hour old. No fix, but -diagnostics now prints some clock info, and examines diffs between temp dir and local clock and complains if they are too different. (>10s, purely arbitrary) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278111 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/Diagnostics.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main/org/apache/tools/ant/Diagnostics.java b/src/main/org/apache/tools/ant/Diagnostics.java index 5d4390e9d..83a61ff65 100644 --- a/src/main/org/apache/tools/ant/Diagnostics.java +++ b/src/main/org/apache/tools/ant/Diagnostics.java @@ -30,6 +30,8 @@ import java.io.IOException; import java.io.FileOutputStream; import java.util.Enumeration; import java.util.Properties; +import java.util.Calendar; +import java.util.TimeZone; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; @@ -238,6 +240,9 @@ public final class Diagnostics { header(out, "Temp dir"); doReportTempDir(out); + + header(out, "Locale information"); + doReportLocale(out); out.println(); } @@ -390,6 +395,7 @@ public final class Diagnostics { /** * try and create a temp file in our temp dir; this * checks that it has space and access. + * We also do some clock reporting. * @param out */ private static void doReportTempDir(PrintStream out) { @@ -406,6 +412,7 @@ public final class Diagnostics { return; } //create the file + long now=System.currentTimeMillis(); File tempFile=null; FileOutputStream fileout = null; try { @@ -418,8 +425,14 @@ public final class Diagnostics { } fileout.close(); fileout=null; + long filetime=tempFile.lastModified(); tempFile.delete(); out.println("Temp dir is writeable"); + long drift=filetime-now; + out.println("temp dir alignment with system clock is "+drift+" ms"); + if(drift>10000) { + out.println("Warning: big clock drift -maybe a network filesystem"); + } } catch (IOException e) { out.println("Failed to create a temporary file in the temp dir " + tempdir); @@ -430,6 +443,19 @@ public final class Diagnostics { tempFile.delete(); } } + } + + /** + * Report locale information + * @param out + */ + private static void doReportLocale(PrintStream out) { + //calendar stuff. + Calendar cal = Calendar.getInstance(); + TimeZone tz = cal.getTimeZone(); + long now = System.currentTimeMillis(); + out.println("Timezone "+tz.getDisplayName() + + " offset="+tz.getOffset(now)); } }