Skip to content
Permalink
Browse files

[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 e603b100889efb71cc71949dc9df7d8eeae5256a
@@ -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;
@@ -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);
@@ -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;

/**
@@ -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;
@@ -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;
@@ -63,9 +64,9 @@
try {
hack.open();
fail();
} catch (FileNotFoundException x) {
} catch (FileNotFoundException | NoSuchFileException x) {
// OK
}
}

}
}

0 comments on commit e603b10

Please sign in to comment.
You can’t perform that action at this time.