You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/01/15 09:37:58 UTC

[GitHub] [logging-log4j2] strugerk opened a new pull request #703: fix deleteAction can't distinguish basePath of symbolicLink

strugerk opened a new pull request #703:
URL: https://github.com/apache/logging-log4j2/pull/703


   fix Appenders DeleteAction didn't work when basepath is symbolicLink.
   jira:https://issues.apache.org/jira/browse/LOG4J2-3342
   
   ![image](https://user-images.githubusercontent.com/37694724/149617084-6f02f4bb-f3d1-45ee-bf76-389b289c2f25.png)
   ![image](https://user-images.githubusercontent.com/37694724/149616974-1c89645c-4b31-4319-ba15-61ea24233214.png)
   
   getSortedPaths should return subFile [log4j-shix-....log],but it only return currentFile dirName [log/file]
   problem:Files.walkFileTree api  in java.nio can't list File directly when file is symbolicLink ,it need do someThing to deal with it 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory commented on a change in pull request #703: fix deleteAction can't distinguish basePath of symbolicLink

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #703:
URL: https://github.com/apache/logging-log4j2/pull/703#discussion_r785303138



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java
##########
@@ -103,7 +103,15 @@ public boolean execute(final FileVisitor<Path> visitor) throws IOException {
      * @return the base path (all lookups resolved)
      */
     public Path getBasePath() {
-        return Paths.get(subst.replace(getBasePathString()));
+        Path path = Paths.get(subst.replace(getBasePathString()));
+        if (Files.isSymbolicLink(path)) {
+            try {
+                path = Files.readSymbolicLink(path);
+            } catch (IOException e) {
+                e.printStackTrace();

Review comment:
       Also, should the replace call happen, before, after, or both?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory commented on a change in pull request #703: fix deleteAction can't distinguish basePath of symbolicLink

Posted by GitBox <gi...@apache.org>.
garydgregory commented on a change in pull request #703:
URL: https://github.com/apache/logging-log4j2/pull/703#discussion_r785303041



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java
##########
@@ -103,7 +103,15 @@ public boolean execute(final FileVisitor<Path> visitor) throws IOException {
      * @return the base path (all lookups resolved)
      */
     public Path getBasePath() {
-        return Paths.get(subst.replace(getBasePathString()));
+        Path path = Paths.get(subst.replace(getBasePathString()));
+        if (Files.isSymbolicLink(path)) {
+            try {
+                path = Files.readSymbolicLink(path);
+            } catch (IOException e) {
+                e.printStackTrace();

Review comment:
       Printing the stack trace is a no-no. Either recover from the problem, propagate, or log to the status logger, I'm not sure which is best here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] strugerk commented on a change in pull request #703: fix deleteAction can't distinguish basePath of symbolicLink

Posted by GitBox <gi...@apache.org>.
strugerk commented on a change in pull request #703:
URL: https://github.com/apache/logging-log4j2/pull/703#discussion_r785308866



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java
##########
@@ -103,7 +103,15 @@ public boolean execute(final FileVisitor<Path> visitor) throws IOException {
      * @return the base path (all lookups resolved)
      */
     public Path getBasePath() {
-        return Paths.get(subst.replace(getBasePathString()));
+        Path path = Paths.get(subst.replace(getBasePathString()));
+        if (Files.isSymbolicLink(path)) {
+            try {
+                path = Files.readSymbolicLink(path);
+            } catch (IOException e) {
+                e.printStackTrace();

Review comment:
       ok, I think we should throw out the exception.  
   It's necessary to capture the exception , because this IOException has been caught outside.
   The status logger can also be printed when handling exceptions externally




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] strugerk commented on a change in pull request #703: fix deleteAction can't distinguish basePath of symbolicLink

Posted by GitBox <gi...@apache.org>.
strugerk commented on a change in pull request #703:
URL: https://github.com/apache/logging-log4j2/pull/703#discussion_r785426539



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java
##########
@@ -103,7 +103,15 @@ public boolean execute(final FileVisitor<Path> visitor) throws IOException {
      * @return the base path (all lookups resolved)
      */
     public Path getBasePath() {
-        return Paths.get(subst.replace(getBasePathString()));
+        Path path = Paths.get(subst.replace(getBasePathString()));
+        if (Files.isSymbolicLink(path)) {
+            try {
+                path = Files.readSymbolicLink(path);
+            } catch (IOException e) {
+                e.printStackTrace();

Review comment:
       I hava changed code,but  compile fail,do you know why? By the way,it compile normally  in my local.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org