Skip to content
Permalink
Browse files

JENKINS-46132 - Fix the test for 2.88.1 baseline.

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 8ad5d1db9131b2973c4588359a6b22e50469e8bc
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/main/java/com/cloudbees/jenkins/support/api/FilePathContent.java
@@ -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
@@ -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) {
@@ -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);

0 comments on commit 8ad5d1d

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