Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-42934] A couple of places where FileNotFoundException may be…
… replaced by NoSuchFileException by JVM shenanigans
  • Loading branch information
stephenc committed Mar 21, 2017
1 parent 218d0a5 commit e603b10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/cli/BuildCommand.java
Expand Up @@ -44,6 +44,7 @@
import hudson.util.EditDistance;
import hudson.util.StreamTaskListener;

import java.nio.file.NoSuchFileException;
import jenkins.scm.SCMDecisionHandler;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
Expand Down Expand Up @@ -189,7 +190,7 @@ protected int run() throws Exception {
b.writeWholeLogTo(stdout);
break;
}
catch (FileNotFoundException e) {
catch (FileNotFoundException | NoSuchFileException e) {
if ( i == retryCnt ) {
Exception myException = new AbortException();
myException.initCause(e);
Expand Down
Expand Up @@ -29,6 +29,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.StandardOpenOption;

/**
Expand Down Expand Up @@ -56,7 +57,7 @@ private synchronized OutputStream current() throws IOException {
try {
current = Files.newOutputStream(out.toPath(), StandardOpenOption.CREATE,
appendOnNextOpen ? StandardOpenOption.APPEND : StandardOpenOption.TRUNCATE_EXISTING);
} catch (FileNotFoundException e) {
} catch (FileNotFoundException | NoSuchFileException e) {
throw new IOException("Failed to open "+out,e);
}
return current;
Expand Down
5 changes: 3 additions & 2 deletions core/src/test/java/jenkins/util/VirtualFileTest.java
Expand Up @@ -29,6 +29,7 @@
import hudson.model.TaskListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.nio.file.NoSuchFileException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
Expand Down Expand Up @@ -63,9 +64,9 @@ public class VirtualFileTest {
try {
hack.open();
fail();
} catch (FileNotFoundException x) {
} catch (FileNotFoundException | NoSuchFileException x) {
// OK
}
}

}
}

0 comments on commit e603b10

Please sign in to comment.