Author: kkolinko
Date: Tue Aug 12 13:49:51 2014
New Revision: 1617475

URL: http://svn.apache.org/r1617475
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56801
Improve performance of org.apache.tomcat.util.file.Matcher which is to filter 
JARs for scanning during web application start. Based on a patch by Sheldon 
Shao.

It is backport of r1615876 and r1617470.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/file/Matcher.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1615876,1617470

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/file/Matcher.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/file/Matcher.java?rev=1617475&r1=1617474&r2=1617475&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/file/Matcher.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/file/Matcher.java Tue Aug 
12 13:49:51 2014
@@ -45,14 +45,16 @@ public final class Matcher {
      *         file name, or <code>false</code> otherwise.
      */
     public static boolean matchName(Set<String> patternSet, String fileName) {
+        char[] fileNameArray = fileName.toCharArray();
         for (String pattern: patternSet) {
-            if (match(pattern, fileName, true)) {
+            if (match(pattern, fileNameArray, true)) {
                 return true;
             }
         }
         return false;
     }
 
+
     /**
      * Tests whether or not a string matches against a pattern.
      * The pattern may contain two special characters:<br>
@@ -61,8 +63,8 @@ public final class Matcher {
      *
      * @param pattern The pattern to match against.
      *                Must not be <code>null</code>.
-     * @param str     The string which must be matched against the pattern.
-     *                Must not be <code>null</code>.
+     * @param str     The string which must be matched against the
+     *                pattern. Must not be <code>null</code>.
      * @param caseSensitive Whether or not matching should be performed
      *                        case sensitively.
      *
@@ -71,9 +73,32 @@ public final class Matcher {
      *         or <code>false</code> otherwise.
      */
     public static boolean match(String pattern, String str,
+            boolean caseSensitive) {
+
+        return match(pattern, str.toCharArray(), caseSensitive);
+    }
+
+
+    /**
+     * Tests whether or not a string matches against a pattern.
+     * The pattern may contain two special characters:<br>
+     * '*' means zero or more characters<br>
+     * '?' means one and only one character
+     *
+     * @param pattern The pattern to match against.
+     *                Must not be <code>null</code>.
+     * @param strArr  The character array which must be matched against the
+     *                pattern. Must not be <code>null</code>.
+     * @param caseSensitive Whether or not matching should be performed
+     *                        case sensitively.
+     *
+     *
+     * @return <code>true</code> if the string matches against the pattern,
+     *         or <code>false</code> otherwise.
+     */
+    private static boolean match(String pattern, char[] strArr,
                                 boolean caseSensitive) {
         char[] patArr = pattern.toCharArray();
-        char[] strArr = str.toCharArray();
         int patIdxStart = 0;
         int patIdxEnd = patArr.length - 1;
         int strIdxStart = 0;

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1617475&r1=1617474&r2=1617475&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Aug 12 13:49:51 2014
@@ -89,6 +89,12 @@
         application. (markt)
       </fix>
       <fix>
+        <bug>56801</bug>: Improve performance of
+        <code>org.apache.tomcat.util.file.Matcher</code> which is to filter 
JARs
+        for scanning during web application start. Based on a patch by Sheldon
+        Shao. (kkolinko)
+      </fix>
+      <fix>
         <bug>56825</bug>: Enable pre-emptive authentication to work with the
         SSL authenticator. Based on a patch by jlmonteiro. (markt)
       </fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to