Details
-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
Occurs on Windows, not confirmed on other platforms.
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.
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; } ... }
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.