Author: jfclere
Date: Mon Apr 29 09:07:33 2013
New Revision: 1476930

URL: http://svn.apache.org/r1476930
Log:
commit accepted patch.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1476930&r1=1476929&r2=1476930&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Mon Apr 29 09:07:33 2013
@@ -31,13 +31,6 @@ PATCHES ACCEPTED TO BACKPORT:
 PATCHES PROPOSED TO BACKPORT:
   [ New proposals should be added at the end of the list ]
 
-* Improve method cache handling in SecurityUtil class.
-  Add caching for Comet methods and simplify cache lookup code.
-  It is backport of r728776 (BZ 46304) and r1429360
-  
http://people.apache.org/~kkolinko/patches/2013-01-05_tc6_46304_SecurityUtil.patch
-  +1: kkolinko, schultz, markt
-  -1:
-
 * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54615
   Update to Eclipse JDT Compiler 4.2.2
   http://people.apache.org/~kkolinko/patches/2013-03-26_tc6_eclipse422.patch

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java?rev=1476930&r1=1476929&r2=1476930&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/security/SecurityUtil.java 
Mon Apr 29 09:07:33 2013
@@ -39,8 +39,8 @@ import org.apache.catalina.util.StringMa
 /**
  * This utility class associates a <code>Subject</code> to the current 
  * <code>AccessControlContext</code>. When a <code>SecurityManager</code> is
- * used, * the container will always associate the called thread with an 
- * AccessControlContext * containing only the principal of the requested
+ * used, the container will always associate the called thread with an 
+ * AccessControlContext containing only the principal of the requested
  * Servlet/Filter.
  *
  * This class uses reflection to invoke the invoke methods.
@@ -49,16 +49,23 @@ import org.apache.catalina.util.StringMa
  */
 
 public final class SecurityUtil{
-    
-    private final static int INIT= 0;
-    private final static int SERVICE = 1;
-    private final static int DOFILTER = 1;
-    private final static int DESTROY = 2;
-    
-    private final static String INIT_METHOD = "init";
-    private final static String DOFILTER_METHOD = "doFilter";
-    private final static String SERVICE_METHOD = "service";
-    private final static String DESTROY_METHOD = "destroy";
+
+    // Note that indexes overlap.
+    // A Servlet uses "init", "service", "event", "destroy".
+    // A Filter uses "doFilter", "doFilterEvent", "destroy".
+    private static final int INIT= 0;
+    private static final int SERVICE = 1;
+    private static final int DOFILTER = 1;
+    private static final int EVENT = 2;
+    private static final int DOFILTEREVENT = 2;
+    private static final int DESTROY = 3;
+
+    private static final String INIT_METHOD = "init";
+    private static final String DOFILTER_METHOD = "doFilter";
+    private static final String SERVICE_METHOD = "service";
+    private static final String EVENT_METHOD = "event";
+    private static final String DOFILTEREVENT_METHOD = "doFilterEvent";
+    private static final String DESTROY_METHOD = "destroy";
    
     /**
      * Cache every object for which we are creating method on it.
@@ -335,19 +342,19 @@ public final class SecurityUtil{
      */
     private static Method findMethod(Method[] methodsCache,
                                      String methodName){
-        if (methodName.equalsIgnoreCase(INIT_METHOD) 
-                && methodsCache[INIT] != null){
+        if (methodName.equals(INIT_METHOD)){
             return methodsCache[INIT];
-        } else if (methodName.equalsIgnoreCase(DESTROY_METHOD) 
-                && methodsCache[DESTROY] != null){
-            return methodsCache[DESTROY];            
-        } else if (methodName.equalsIgnoreCase(SERVICE_METHOD) 
-                && methodsCache[SERVICE] != null){
+        } else if (methodName.equals(DESTROY_METHOD)){
+            return methodsCache[DESTROY];
+        } else if (methodName.equals(SERVICE_METHOD)){
             return methodsCache[SERVICE];
-        } else if (methodName.equalsIgnoreCase(DOFILTER_METHOD) 
-                && methodsCache[DOFILTER] != null){
-            return methodsCache[DOFILTER];          
-        } 
+        } else if (methodName.equals(DOFILTER_METHOD)){
+            return methodsCache[DOFILTER];
+        } else if (methodName.equals(EVENT_METHOD)){
+            return methodsCache[EVENT];
+        } else if (methodName.equals(DOFILTEREVENT_METHOD)){
+            return methodsCache[DOFILTEREVENT];
+        }
         return null;
     }
     
@@ -369,22 +376,26 @@ public final class SecurityUtil{
             throws Exception{
         
         if ( methodsCache == null){
-            methodsCache = new Method[3];
+            methodsCache = new Method[4];
         }               
                 
         Method method = 
             targetObject.getClass().getMethod(methodName, targetType); 
 
-        if (methodName.equalsIgnoreCase(INIT_METHOD)){
+        if (methodName.equals(INIT_METHOD)){
             methodsCache[INIT] = method;
-        } else if (methodName.equalsIgnoreCase(DESTROY_METHOD)){
+        } else if (methodName.equals(DESTROY_METHOD)){
             methodsCache[DESTROY] = method;
-        } else if (methodName.equalsIgnoreCase(SERVICE_METHOD)){
+        } else if (methodName.equals(SERVICE_METHOD)){
             methodsCache[SERVICE] = method;
-        } else if (methodName.equalsIgnoreCase(DOFILTER_METHOD)){
+        } else if (methodName.equals(DOFILTER_METHOD)){
             methodsCache[DOFILTER] = method;
-        } 
-         
+        } else if (methodName.equals(EVENT_METHOD)){
+            methodsCache[EVENT] = method;
+        } else if (methodName.equals(DOFILTEREVENT_METHOD)){
+            methodsCache[DOFILTEREVENT] = method;
+        }
+
         objectCache.put(targetObject, methodsCache );
                                            
         return method;



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

Reply via email to