lrgrz opened a new issue, #1280:
URL: https://github.com/apache/logging-log4j2/issues/1280

   While looking for eligible files, AbstractRolloverStrategy makes unnecessary 
IO access if `logfilePattern` doesn't match `PATTERN_COUNTER`. `File parent` is 
never used in such case:
   
   ```java
      protected SortedMap<Integer, Path> getEligibleFiles(final String 
currentFile, final String path,
               final String logfilePattern, final boolean isAscending) {
           final TreeMap<Integer, Path> eligibleFiles = new TreeMap<>();
           final File file = new File(path);
           File parent = file.getParentFile();
           if (parent == null) {
               parent = new File(".");
           } else {
               parent.mkdirs();
           }
           if (!PATTERN_COUNTER.matcher(logfilePattern).matches()) {
               return eligibleFiles;
           }
   ```
   
   The check can be skipped in following way:
   ```
       protected SortedMap<Integer, Path> getEligibleFiles(final String 
currentFile, final String path,
               final String logfilePattern, final boolean isAscending) {
           final TreeMap<Integer, Path> eligibleFiles = new TreeMap<>();
           if (!PATTERN_COUNTER.matcher(logfilePattern).matches()) {
               return eligibleFiles;
           }
   ```
   
   Beyond being a little bit more efficient, it also prevents creation of empty 
dirs, if they no longer exists.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to