Skip to content

Commit

Permalink
[FIXED JENKINS-15156] Initialize AbstractLazyLoadRunMap.dir for newly…
Browse files Browse the repository at this point in the history
… created jobs
  • Loading branch information
tsartarzan committed Feb 3, 2013
1 parent dbd6b53 commit 2feb19e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/src/main/java/hudson/model/AbstractProject.java
Expand Up @@ -162,7 +162,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* {@link Run#getPreviousBuild()}
*/
@Restricted(NoExternalUse.class)
protected transient RunMap<R> builds = new RunMap<R>();
protected transient RunMap<R> builds;

/**
* The quiet period. Null to delegate to the system default.
Expand Down Expand Up @@ -271,6 +271,12 @@ public void onCreatedFromScratch() {
super.onCreatedFromScratch();
// solicit initial contributions, especially from TransientProjectActionFactory
updateTransientActions();
assert builds==null;
builds = new RunMap<R>(getBuildDir(), new Constructor<R>() {
public R create(File dir) throws IOException {
return loadBuild(dir);
}
});
}

@Override
Expand Down
Expand Up @@ -203,8 +203,8 @@ protected void initBaseDir(File dir) {
private void loadIdOnDisk() {
String[] buildDirs = dir.list(createDirectoryFilter());
if (buildDirs==null) {
// the job may just have been created
buildDirs=EMPTY_STRING_ARRAY;
LOGGER.log(Level.WARNING, "failed to load list of builds from {0}", dir);
}
// wrap into ArrayList to enable mutation
Arrays.sort(buildDirs);
Expand Down Expand Up @@ -625,6 +625,7 @@ protected R load(int n, Index editInPlace) {


protected R load(String id, Index editInPlace) {
assert dir != null;
R v = load(new File(dir, id), editInPlace);
if (v==null && editInPlace!=null) {
// remember the failure.
Expand Down

0 comments on commit 2feb19e

Please sign in to comment.