Skip to content

Commit cbb1e3d

Browse files
authored
Merge pull request #581 from schlosna/ds/file-filter-regex
[LOGBACK-1409] FileFilterUtil.filesInFolderMatchingStemRegex resuses compiled pattern
2 parents 475281b + ac823db commit cbb1e3d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

logback-core/src/main/java/ch/qos/logback/core/rolling/helper/FileFilterUtil.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ public static File[] filesInFolderMatchingStemRegex(File file, final String stem
7979
if (!file.exists() || !file.isDirectory()) {
8080
return new File[0];
8181
}
82-
return file.listFiles(new FilenameFilter() {
83-
public boolean accept(File dir, String name) {
84-
return name.matches(stemRegex);
85-
}
86-
});
82+
83+
Pattern regex = Pattern.compile(stemRegex);
84+
return file.listFiles((dir, name) -> regex.matcher(name).matches());
8785
}
8886

8987
static public int findHighestCounter(File[] matchingFileArray, final String stemRegex) {

0 commit comments

Comments
 (0)