From 760436d4e4ce1a0789026931d104ab50e9fbfbfe Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 28 Aug 2008 18:22:12 +0000 Subject: [PATCH] [HUDSON-1461] reducing the amount of bogus error messages that Hudson prints during start up. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11804 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Run.java | 2 +- core/src/main/java/hudson/model/RunMap.java | 28 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 1eae5bd640..4c67270d1e 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -188,7 +188,7 @@ public abstract class Run ,RunT extends Run> extends AbstractMap imp * Used to create new instance of {@link Run}. */ public synchronized void load(Job job, Constructor cons) { + final SimpleDateFormat formatter = Run.ID_FORMATTER.get(); + TreeMap builds = new TreeMap(RunMap.COMPARATOR); File buildDir = job.getBuildDir(); buildDir.mkdirs(); String[] buildDirs = buildDir.list(new FilenameFilter() { public boolean accept(File dir, String name) { - // HUDSON-1461 sometimes create bogus data directories with impossible dates, such as year 0. - // Date object doesn't roundtrip year 0 (year is -2,-1,+1,+2,... and there's no zero), - // so we eventually fail to load this data. - // so don't even bother trying.k + // HUDSON-1461 sometimes create bogus data directories with impossible dates, such as year 0, April 31st, + // or August 0th. Date object doesn't roundtrip those, so we eventually fail to load this data. + // Don't even bother trying. + if (!isCorrectDate(name)) { + LOGGER.fine("Skipping "+new File(dir,name)); + return false; + } return !name.startsWith("0000") && new File(dir,name).isDirectory(); } + + private boolean isCorrectDate(String name) { + try { + if(formatter.format(formatter.parse(name)).equals(name)) + return true; + } catch (ParseException e) { + // fall through + } + return false; + } }); for( String build : buildDirs ) { @@ -187,4 +205,6 @@ public final class RunMap> extends AbstractMap imp reset(builds); } + + private static final Logger LOGGER = Logger.getLogger(RunMap.class.getName()); }