Handle Windows permissions when POSIX not supported
Handle the UnsupportedOperationException that is thrown when attempting to use the Files.getPosixFilePermissions() under Windows (as POSIX is not supported) by using the File.setExecutable() instead in that scenario.
@@ -1206,6 +1206,7 @@ public class InstanceServiceImpl implements InstanceService {
}
private void makeFileExecutable(File serviceFile) throws IOException {
+ try {
Set<PosixFilePermission> permissions = new HashSet<>();
permissions.add(PosixFilePermission.OWNER_EXECUTE);
permissions.add(PosixFilePermission.GROUP_EXECUTE);
@@ -1216,6 +1217,11 @@ public class InstanceServiceImpl implements InstanceService {
filePermissions.addAll(permissions);
Files.setPosixFilePermissions(serviceFile.toPath(), filePermissions);
}
+ catch (UnsupportedOperationException ex)
+ {
+ serviceFile.setExecutable(true, false);
+ }
+ }
private void copy(File source, File destination) throws IOException {
if (source.getName().equals("cache.lock")) {
