提交 760436d4 编写于 作者: K kohsuke

[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
上级 d4702598
......@@ -188,7 +188,7 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
getDataFile().unmarshal(this); // load the rest of the data
}
private static long parseTimestampFromBuildDir(File buildDir) throws IOException {
/*package*/ static long parseTimestampFromBuildDir(File buildDir) throws IOException {
try {
return ID_FORMATTER.get().parse(buildDir.getName()).getTime();
} catch (ParseException e) {
......
......@@ -10,6 +10,9 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.logging.Logger;
import java.text.SimpleDateFormat;
import java.text.ParseException;
/**
* {@link Map} from build number to {@link Run}.
......@@ -157,17 +160,32 @@ public final class RunMap<R extends Run<?,R>> extends AbstractMap<Integer,R> imp
* Used to create new instance of {@link Run}.
*/
public synchronized void load(Job job, Constructor<R> cons) {
final SimpleDateFormat formatter = Run.ID_FORMATTER.get();
TreeMap<Integer,R> builds = new TreeMap<Integer,R>(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<R extends Run<?,R>> extends AbstractMap<Integer,R> imp
reset(builds);
}
private static final Logger LOGGER = Logger.getLogger(RunMap.class.getName());
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册