You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2017/06/21 01:56:50 UTC

logging-log4j2 git commit: [LOG4J2-1699] Configurable Log File Permissions with PosixFilePermission. Reformat the new method definePathAttributeView().

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 95da4d8bb -> b92934bc6


[LOG4J2-1699] Configurable Log File Permissions with
PosixFilePermission. Reformat the new method definePathAttributeView().

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b92934bc
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b92934bc
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b92934bc

Branch: refs/heads/master
Commit: b92934bc671ef990d371ccb72fbf474f09a680ad
Parents: 95da4d8
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Jun 20 18:56:49 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Jun 20 18:56:49 2017 -0700

----------------------------------------------------------------------
 .../log4j/core/appender/FileManager.java        | 46 ++++++++++----------
 1 file changed, 22 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b92934bc/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
index c07afc2..511965d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java
@@ -170,33 +170,31 @@ public class FileManager extends OutputStreamManager {
     }
 
     protected void definePathAttributeView(final Path path) throws IOException {
-      if (filePermissions != null || fileOwner != null || fileGroup != null) {
-        // FileOutputStream may not create new file on all jvm
-        path.toFile().createNewFile();
+        if (filePermissions != null || fileOwner != null || fileGroup != null) {
+            // FileOutputStream may not create new file on all jvm
+            path.toFile().createNewFile();
 
-        final PosixFileAttributeView view = Files.getFileAttributeView(path,
-            PosixFileAttributeView.class);
-        if (view != null) {
-          final UserPrincipalLookupService lookupService = FileSystems.getDefault()
-              .getUserPrincipalLookupService();
-          if (fileOwner != null) {
-            final UserPrincipal userPrincipal = lookupService.lookupPrincipalByName(fileOwner);
-            if (userPrincipal != null) {
-              view.setOwner(userPrincipal);
-            }
-          }
-          if (fileGroup != null) {
-            final GroupPrincipal groupPrincipal = lookupService
-                .lookupPrincipalByGroupName(fileGroup);
-            if (groupPrincipal != null) {
-              view.setGroup(groupPrincipal);
+            final PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView.class);
+            if (view != null) {
+                final UserPrincipalLookupService lookupService = FileSystems.getDefault()
+                        .getUserPrincipalLookupService();
+                if (fileOwner != null) {
+                    final UserPrincipal userPrincipal = lookupService.lookupPrincipalByName(fileOwner);
+                    if (userPrincipal != null) {
+                        view.setOwner(userPrincipal);
+                    }
+                }
+                if (fileGroup != null) {
+                    final GroupPrincipal groupPrincipal = lookupService.lookupPrincipalByGroupName(fileGroup);
+                    if (groupPrincipal != null) {
+                        view.setGroup(groupPrincipal);
+                    }
+                }
+                if (filePermissions != null) {
+                    view.setPermissions(filePermissions);
+                }
             }
-          }
-          if (filePermissions != null) {
-            view.setPermissions(filePermissions);
-          }
         }
-      }
     }
 
     @Override