From 3c2b50ecfe1c58f64b32d30a3f96e647671f7d03 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 1 May 2013 20:12:59 -0400 Subject: [PATCH] [FIXED JENKINS-17681] Do not try to call resolveSymlink on a nonexistent link as you will just get an IOException, breaking peephole permalinks in some Windows environments. --- changelog.html | 3 +++ core/src/main/java/hudson/Util.java | 4 ++++ .../src/main/java/jenkins/model/PeepholePermalink.java | 10 +++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/changelog.html b/changelog.html index ca690e085b..8e738d6328 100644 --- a/changelog.html +++ b/changelog.html @@ -58,6 +58,9 @@ Upcoming changes
  • Display Name is not shown. (issue 17715) +
  • + Symlink handling problem with build permalinks on Windows. + (issue 17681)
  • List views missing a required field were unloadable. (issue 15309) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 1365bca2be..511d9eefa8 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -1200,6 +1200,10 @@ public class Util { } catch (ClassNotFoundException x3) { assert false : x3; // should be Java 7+ here } + if (x2.getClass().getName().equals("java.nio.file.FileSystemException")) { + // Thrown ("Incorrect function.") on JDK 7u21 in Windows 2012 when called on a non-symlink, rather than NotLinkException, contrary to documentation. Maybe only when not on NTFS? + return null; + } if (x2 instanceof IOException) { throw (IOException) x2; } diff --git a/core/src/main/java/jenkins/model/PeepholePermalink.java b/core/src/main/java/jenkins/model/PeepholePermalink.java index 2e4677a134..397d035743 100644 --- a/core/src/main/java/jenkins/model/PeepholePermalink.java +++ b/core/src/main/java/jenkins/model/PeepholePermalink.java @@ -17,6 +17,7 @@ import javax.annotation.Nullable; import java.io.File; import java.io.IOException; import java.io.StringWriter; +import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -143,6 +144,12 @@ public abstract class PeepholePermalink extends Permalink implements Predicate