Skip to content

Commit

Permalink
JENKINS-46132 - Fix the test for 2.88.1 baseline.
Browse files Browse the repository at this point in the history
The underlying implementation of some of the the FilePath functionality
have changed to NIO. Therefore a `NoSuchFileException` is thrown instead
of the `FileNotFoundException` when file is missing. `FilePathContent`
is update to handle both in the same way. `FileContent` has not been
update since it is still using the old File IO.
  • Loading branch information
duemir committed Dec 19, 2017
1 parent 735f1b2 commit 8ad5d1d
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -28,6 +28,7 @@
import hudson.FilePath;

import java.io.*;
import java.nio.file.NoSuchFileException;

/**
* Content that is stored as a file on a remote disk
Expand All @@ -36,6 +37,10 @@
*/
public class FilePathContent extends Content {

private static boolean isFileNotFound(Throwable e) {
return e instanceof FileNotFoundException || e instanceof NoSuchFileException;
}

private final FilePath file;

public FilePathContent(String name, FilePath file) {
Expand All @@ -50,7 +55,7 @@ public void writeTo(OutputStream os) throws IOException {
} catch (InterruptedException e) {
throw new IOException(e);
} catch (IOException e) {
if (e instanceof FileNotFoundException || e.getCause() instanceof FileNotFoundException) {
if (isFileNotFound(e) || isFileNotFound(e.getCause())) {
OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8");
try {
PrintWriter pw = new PrintWriter(osw, true);
Expand Down

0 comments on commit 8ad5d1d

Please sign in to comment.