brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <>
Subject [GitHub] incubator-brooklyn pull request: Move to java7 setPosixFilePermiss...
Date Tue, 15 Sep 2015 10:03:11 GMT
Github user aledsage commented on a diff in the pull request:
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/io/ ---
    @@ -73,36 +77,11 @@ public static void setFilePermissionsTo700(File file) throws IOException
    -    // When we move to java 7, we can use Files.setPosixFilePermissions
    +    private static final Set<PosixFilePermission> posixPermissions600 = PosixFilePermissions.fromString("rw-------");
         public static void setFilePermissionsTo600(File file) throws IOException {
    -        file.setExecutable(false, false);
    -        file.setReadable(false, false);
    -        file.setWritable(false, false);
    -        file.setReadable(true, true);
    -        file.setWritable(true, true);
    -        boolean setRead = file.setReadable(false, false) & file.setReadable(true,
    -        boolean setWrite = file.setWritable(false, false) & file.setWritable(true,
    -        boolean setExec = file.setExecutable(false, false);
    -        if (setRead && setWrite && setExec) {
    -            if (LOG.isTraceEnabled()) LOG.trace("Set permissions to 600 for file {}",
    -        } else {
    --- End diff --
    The previous code relied on `file.setReadable` returning false, so as to do a single `LOG.warn`
if the file was not accessible. I presume that `Files.setPosixFilePermissions` will throw
an `IOException`.
    I worry about us propagating the exception, without changing the callers. For example,
see `FileBasedStoreObjectAccessor.put`. This will now fail, rather than just writing to the
file without changing the file permission. We'd definitely want the warn (done just once,
rather than many times a second!) in such a situation.

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message