From 606a9e1de9b38621dc018dd36d3ec8adb35e9beb Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 19 Mar 2013 10:13:19 -0400 Subject: [PATCH] File.setWritable should be the first, and if possible only, thing we try for makeWritable. --- core/src/main/java/hudson/Util.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 853e09d9b2..e4a4bc8a40 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -252,6 +252,15 @@ public class Util { */ @IgnoreJRERequirement private static void makeWritable(File f) { + // try JDK6-way of doing it. + try { + if (f.setWritable(true)) { + return; + } + } catch (NoSuchMethodError e) { + // not JDK6 + } + // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); @@ -263,13 +272,6 @@ public class Util { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } - // also try JDK6-way of doing it. - try { - f.setWritable(true); - } catch (NoSuchMethodError e) { - // not JDK6 - } - try {// try libc chmod POSIX posix = PosixAPI.get(); String path = f.getAbsolutePath(); -- GitLab