Skip to content

Commit

Permalink
[JENKINS-13202] 646154f refinement: resolveSymlink is documented to r…
Browse files Browse the repository at this point in the history
…eturn null, not throw an exception, when called on a regular file.
  • Loading branch information
jglick committed Nov 16, 2012
1 parent a8d9397 commit 0552f5a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -61,6 +61,9 @@
<li class=bug>
Build records were broken if timezone was changed while running.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15816">issue 15816</a>)
<li class=bug>
Symlink detection refinement on Java 7.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-13202">issue 13202</a>)
<li class='major bug'>
Displaying massive test suite results could bring down Jenkins.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15818">issue 15818</a>)
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/Util.java
Expand Up @@ -1110,6 +1110,13 @@ public static String resolveSymlink(File link) throws InterruptedException, IOEx
if (x2 instanceof UnsupportedOperationException) {
return null; // no symlinks on this platform
}
try {
if (Class.forName("java.nio.file.NotLinkException").isInstance(x2)) {
return null;
}
} catch (ClassNotFoundException x3) {
assert false : x3; // should be Java 7+ here
}
if (x2 instanceof IOException) {
throw (IOException) x2;
}
Expand Down
1 change: 1 addition & 0 deletions core/src/test/java/hudson/UtilTest.java
Expand Up @@ -171,6 +171,7 @@ public void testSymlink() throws Exception {
File d = Util.createTempDir();
try {
new FilePath(new File(d, "a")).touch(0);
assertNull(Util.resolveSymlink(new File(d, "a")));
Util.createSymlink(d,"a","x", l);
assertEquals("a",Util.resolveSymlink(new File(d,"x")));

Expand Down

0 comments on commit 0552f5a

Please sign in to comment.