logback / LOGBACK-1561 [Open]
SizeAndTimeBasedFNATP counter compute failure

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/LOGBACK-1561

==============================
 Issue created
------------------------------

Rafał Gała created this issue on 23/Jun/21 6:27 PM
Summary:              SizeAndTimeBasedFNATP counter compute failure
Issue Type:           Bug
Assignee:             Logback dev list
Components:           logback-core
Created:              23/Jun/21 6:27 PM
Environment:          Occurs on Windows, not confirmed on other platforms.
Labels:               SizeAndTimeBasedRollingPolicy
Priority:             Minor
Reporter:             Rafał Gała
Description:
  When *TimeBasedRollingPolicy* fileNamePattern is set to just a file, for 
example *toto-%d\{yyyy-MM-dd}-%i.log*, then the following code from 
*SizeAndTimeBasedFNATP* class fails to detect parent directory and assumes 
counter = 0 even if there are already ZIP files in the directory. This leads to 
file name collision during rolling.
  
   
  {code:java}
  void computeCurrentPeriodsHighestCounterValue(final String stemRegex) {
      File file = new File(getCurrentPeriodsFileNameWithoutCompressionSuffix());
      File parentDir = file.getParentFile();
  
      File[] matchingFileArray = 
FileFilterUtil.filesInFolderMatchingStemRegex(parentDir, stemRegex);
  
      if (matchingFileArray == null || matchingFileArray.length == 0) {
          currentPeriodsCounter = 0;
          return;
      }
    ...
  }{code}
  *file.getParentFile()* returns null in this case. The workaround is to prefix 
file name pattern with ./ (*./*toto-%d\{yyyy-MM-dd}-%i.log). I believe the 
current working directory should be used as parent directory when *parentDir* 
resolves to null.


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)

_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-dev

Reply via email to