Thanks,

can you create a Github pull request for this?
That would be much easier to handle.

Gesendet: Donnerstag, 31. Januar 2013 um 17:19 Uhr
Von: "Julian Schmidt" <ju.schm...@gmx.de>
An: jenkinsci-dev@googlegroups.com
Betreff: Possible fix for JENKINS-15156 (builds disappearing from job history)
Hi,

Trying to debug JENKINS-15156 it seems that after creating a new job,
the 'dir' member of its 'AbstractLazyLoadRunMap' of builds is null
until Jenkins is restarted/reload. After the map's members get
garbage-collected, reloading them fails because dir is null, giving
the missing builds.

Below is a patch against revision ce170a60be which for me seems to
solve this.

Regards,
Julian


diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java
index b0a8a19..6b1448f 100644
--- a/core/src/main/java/hudson/model/AbstractProject.java
+++ b/core/src/main/java/hudson/model/AbstractProject.java
@@ -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.
@@ -271,6 +271,12 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
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
diff --git a/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java b/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
index 2129030..3deaf03 100644
--- a/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
+++ b/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java
@@ -203,8 +203,8 @@ public abstract class AbstractLazyLoadRunMap<R> extends AbstractMap<Integer,R> i
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);
@@ -625,6 +625,7 @@ public abstract class AbstractLazyLoadRunMap<R> extends AbstractMap<Integer,R> i


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.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to