Author: rfscholte
Date: Sun Jan 24 18:53:43 2016
New Revision: 1726536

URL: http://svn.apache.org/viewvc?rev=1726536&view=rev
Log:
Replace FileUtils.files with File.listFiles() because it is more efficient, 
especially with a huge and deep temp directory

Modified:
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
    
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java?rev=1726536&r1=1726535&r2=1726536&view=diff
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/test/java/org/apache/maven/doxia/module/fml/FmlParserTest.java
 Sun Jan 24 18:53:43 2016
@@ -20,12 +20,14 @@ package org.apache.maven.doxia.module.fm
  */
 
 import java.io.File;
+import java.io.FileFilter;
 import java.io.FileReader;
 import java.io.Reader;
 import java.io.Writer;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.maven.doxia.parser.AbstractParserTest;
 import org.apache.maven.doxia.parser.Parser;
@@ -56,11 +58,21 @@ public class FmlParserTest
         // AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files 
in ${java.io.tmpdir}
         // Be sure to delete them
         String tmpDir = System.getProperty( "java.io.tmpdir" );
-        String excludes = "fml-*.xsd, xml.xsd";
-        List<String> tmpFiles = FileUtils.getFileNames( new File( tmpDir ), 
excludes, null, true );
-        for ( Iterator<String> it = tmpFiles.iterator(); it.hasNext(); )
+
+        // Using FileFilter, because is it is much faster then 
FileUtils.listFiles 
+        File[] tmpFiles = new File( tmpDir ).listFiles( new FileFilter()
+        {
+            Pattern xsdPatterns = Pattern.compile( "(xml|fml\\-.+)\\.xsd" );
+            
+            @Override
+            public boolean accept( File pathname )
+            {
+                return xsdPatterns.matcher( pathname.getName() ).matches(); 
+            }
+        } );
+        
+        for ( File tmpFile : tmpFiles )
         {
-            File tmpFile = new File( it.next().toString() );
             tmpFile.delete();
         }
     }

Modified: 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
URL: 
http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java?rev=1726536&r1=1726535&r2=1726536&view=diff
==============================================================================
--- 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
 (original)
+++ 
maven/doxia/doxia/trunk/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
 Sun Jan 24 18:53:43 2016
@@ -20,14 +20,14 @@ package org.apache.maven.doxia.module.xh
  */
 
 import java.io.File;
+import java.io.FileFilter;
 import java.util.Iterator;
-import java.util.List;
+import java.util.regex.Pattern;
 
 import org.apache.maven.doxia.parser.AbstractParserTest;
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.impl.SinkEventElement;
 import org.apache.maven.doxia.sink.impl.SinkEventTestingSink;
-import org.codehaus.plexus.util.FileUtils;
 
 /**
  * @author <a href="mailto:[email protected]";>Lars Trieloff</a>
@@ -49,14 +49,24 @@ public class XhtmlParserTest
         // AbstractXmlParser.CachedFileEntityResolver downloads DTD/XSD files 
in ${java.io.tmpdir}
         // Be sure to delete them
         String tmpDir = System.getProperty( "java.io.tmpdir" );
-        String excludes = "xhtml-lat1.ent, xhtml1-transitional.dtd, 
xhtml-special.ent, xhtml-symbol.ent";
-        @SuppressWarnings( "unchecked" )
-        List<String> tmpFiles = FileUtils.getFileNames( new File( tmpDir ), 
excludes, null, true );
-        for ( String filename : tmpFiles )
+
+        // Using FileFilter, because is it is much faster then 
FileUtils.listFiles 
+        File[] tmpFiles = new File( tmpDir ).listFiles( new FileFilter()
+        {
+            Pattern xsdPatterns = Pattern.compile( 
"(xhtml-lat1.ent|xhtml1-transitional.dtd|xhtml-special.ent|xhtml-symbol.ent)" );
+            
+            @Override
+            public boolean accept( File pathname )
+            {
+                return xsdPatterns.matcher( pathname.getName() ).matches(); 
+            }
+        } );
+        
+        for ( File tmpFile : tmpFiles )
         {
-            File tmpFile = new File( filename );
             tmpFile.delete();
         }
+
     }
 
     /** {@inheritDoc} */


Reply via email to