diff --git a/changelog.html b/changelog.html index 2abad278f1..21fc12cdf5 100644 --- a/changelog.html +++ b/changelog.html @@ -58,6 +58,9 @@ Upcoming changes
  • Fixed a reference counting bug in the remoting layer. (commit) +
  • + Avoid repeatedly reading symlinks from disk to resolve build permalinks. + (issue 22822)
  • Show custom build display name in executors widget. (issue 10477) diff --git a/core/src/main/java/jenkins/model/PeepholePermalink.java b/core/src/main/java/jenkins/model/PeepholePermalink.java index d4cb1a39ed..8e92e547d4 100644 --- a/core/src/main/java/jenkins/model/PeepholePermalink.java +++ b/core/src/main/java/jenkins/model/PeepholePermalink.java @@ -10,16 +10,17 @@ import hudson.model.TaskListener; import hudson.model.listeners.RunListener; import hudson.util.AtomicFileWriter; import hudson.util.StreamTaskListener; -import org.apache.commons.io.FileUtils; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.io.StringWriter; import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.commons.io.FileUtils; /** * Convenient base implementation for {@link Permalink}s that satisfy @@ -59,6 +60,10 @@ import java.util.logging.Logger; * @since 1.507 */ public abstract class PeepholePermalink extends Permalink implements Predicate> { + + /** JENKINS-22822: avoids rereading symlinks */ + static final Map symlinks = new HashMap(); + /** * Checks if the given build satisfies the peep-hole criteria. * @@ -139,7 +144,7 @@ public abstract class PeepholePermalink extends Permalink implements PredicateId symlink Util.createSymlink(job.getBuildDir(),b.getId(),target,TaskListener.NULL); } - writeSymlink(cache, String.valueOf(n)); + writeSymlink(cache, target); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to update "+job+" "+getId()+" permalink for " + b, e); cache.delete(); @@ -156,15 +161,30 @@ public abstract class PeepholePermalink extends Permalink implements Predicate