Skip to content

Commit 4dcf99a

Browse files
author
Niall Pemberton
committed
IO-240 ensure cvsFilter and svnFilter are only created once.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@982437 13f79535-47bb-0310-9956-ffa450edef68
1 parent ae6f41b commit 4dcf99a

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

src/java/org/apache/commons/io/filefilter/FileFilterUtils.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,12 @@ public static IOFileFilter magicNumberFileFilter(byte[] magicNumber, long offset
380380

381381
//-----------------------------------------------------------------------
382382
/* Constructed on demand and then cached */
383-
private static IOFileFilter cvsFilter;
383+
private static final IOFileFilter cvsFilter = notFileFilter(
384+
andFileFilter(directoryFileFilter(), nameFileFilter("CVS")));;
384385

385386
/* Constructed on demand and then cached */
386-
private static IOFileFilter svnFilter;
387+
private static final IOFileFilter svnFilter = svnFilter = notFileFilter(
388+
andFileFilter(directoryFileFilter(), nameFileFilter(".svn")));
387389

388390
/**
389391
* Decorates a filter to make it ignore CVS directories.
@@ -395,10 +397,6 @@ public static IOFileFilter magicNumberFileFilter(byte[] magicNumber, long offset
395397
* @since Commons IO 1.1 (method existed but had bug in 1.0)
396398
*/
397399
public static IOFileFilter makeCVSAware(IOFileFilter filter) {
398-
if (cvsFilter == null) {
399-
cvsFilter = notFileFilter(
400-
andFileFilter(directoryFileFilter(), nameFileFilter("CVS")));
401-
}
402400
if (filter == null) {
403401
return cvsFilter;
404402
} else {
@@ -416,10 +414,6 @@ public static IOFileFilter makeCVSAware(IOFileFilter filter) {
416414
* @since Commons IO 1.1
417415
*/
418416
public static IOFileFilter makeSVNAware(IOFileFilter filter) {
419-
if (svnFilter == null) {
420-
svnFilter = notFileFilter(
421-
andFileFilter(directoryFileFilter(), nameFileFilter(".svn")));
422-
}
423417
if (filter == null) {
424418
return svnFilter;
425419
} else {

0 commit comments

Comments
 (0)