diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 373eccb72d..cfc05836dc 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -42,7 +42,6 @@ import hudson.model.AbstractProject; import hudson.model.Computer; import hudson.model.Item; import hudson.model.TaskListener; -import hudson.os.PosixException; import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.DelegatingCallable; @@ -1985,7 +1984,7 @@ public final class FilePath implements SerializableOnlyOverRemoting { * @since 1.311 * @see #chmod(int) */ - public int mode() throws IOException, InterruptedException, PosixException { + public int mode() throws IOException, InterruptedException { if (!isUnix()) return -1; return act(new Mode()); } diff --git a/core/src/main/java/hudson/os/PosixException.java b/core/src/main/java/hudson/os/PosixException.java index be10886825..b741e94246 100644 --- a/core/src/main/java/hudson/os/PosixException.java +++ b/core/src/main/java/hudson/os/PosixException.java @@ -1,9 +1,13 @@ package hudson.os; +import java.io.IOException; + /** * Indicates an error during POSIX API call. * @author Kohsuke Kawaguchi + * @deprecated use {@link IOException} */ +@Deprecated public class PosixException extends RuntimeException { public PosixException(String message) { diff --git a/core/src/main/java/hudson/util/IOUtils.java b/core/src/main/java/hudson/util/IOUtils.java index 1a6d626eb4..bf16104d4c 100644 --- a/core/src/main/java/hudson/util/IOUtils.java +++ b/core/src/main/java/hudson/util/IOUtils.java @@ -4,7 +4,6 @@ import static hudson.Util.fileToPath; import hudson.Functions; import hudson.Util; -import hudson.os.PosixException; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File; @@ -129,15 +128,11 @@ public class IOUtils { * care about access permissions. *

If the file is symlink, the mode is that of the link target, not the link itself. * @return a file mode, or -1 if not on Unix - * @throws PosixException if the file could not be statted, e.g. broken symlink + * @throws IOException if the file could not be statted, e.g. broken symlink */ - public static int mode(File f) throws PosixException { + public static int mode(File f) throws IOException { if (Functions.isWindows()) return -1; - try { - return Util.permissionsToMode(Files.getPosixFilePermissions(fileToPath(f))); - } catch (IOException cause) { - throw new PosixException("Unable to get file permissions", cause); - } + return Util.permissionsToMode(Files.getPosixFilePermissions(fileToPath(f))); } /** diff --git a/core/src/main/java/hudson/util/io/TarArchiver.java b/core/src/main/java/hudson/util/io/TarArchiver.java index ae66154f68..b38ee7e2ad 100644 --- a/core/src/main/java/hudson/util/io/TarArchiver.java +++ b/core/src/main/java/hudson/util/io/TarArchiver.java @@ -25,7 +25,6 @@ package hudson.util.io; import hudson.Functions; -import hudson.os.PosixException; import hudson.util.FileVisitor; import hudson.util.IOUtils; import java.io.File; @@ -62,7 +61,7 @@ final class TarArchiver extends Archiver { if (mode != -1) { e.setMode(mode); } - } catch (PosixException x) { + } catch (IOException x) { // ignore } diff --git a/core/src/main/java/jenkins/util/VirtualFile.java b/core/src/main/java/jenkins/util/VirtualFile.java index e40dd994a1..7dfd72a3d0 100644 --- a/core/src/main/java/jenkins/util/VirtualFile.java +++ b/core/src/main/java/jenkins/util/VirtualFile.java @@ -29,7 +29,6 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.FilePath; import hudson.Util; import hudson.model.DirectoryBrowserSupport; -import hudson.os.PosixException; import hudson.remoting.Callable; import hudson.remoting.Channel; import hudson.remoting.RemoteInputStream; @@ -1026,7 +1025,7 @@ public abstract class VirtualFile implements Comparable, Serializab @Override public int mode() throws IOException { try { return f.mode(); - } catch (InterruptedException | PosixException x) { + } catch (InterruptedException x) { throw new IOException(x); } }