Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49613
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 22 Jul 2010 14:36:15 +0000 (14:36 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 22 Jul 2010 14:36:15 +0000 (14:36 +0000)
Improve performance for multiple calls to Request.getAttributeNames() when using SSL. Patch provided by Sampo Savolainen.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@966692 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Request.java
webapps/docs/changelog.xml

index 14ea7a0..7289235 100644 (file)
@@ -194,6 +194,13 @@ public class Request
 
 
     /**
+     * Flag that indicates if SSL attributes have been parsed to improve
+     * performance for applications (usually frameworks) that make multiple
+     * calls to {@link Request#getAttributeNames()}.
+     */
+    protected boolean sslAttributesParsed = false;
+
+    /**
      * List of read only attributes for this Request.
      */
     private HashMap<String,Object> readOnlyAttributes =
@@ -478,6 +485,7 @@ public class Request
         localName = null;
 
         attributes.clear();
+        sslAttributesParsed = false;
         notes.clear();
         cookies = null;
 
@@ -937,6 +945,7 @@ public class Request
                 attributes.put(Globals.SSL_SESSION_MGR_ATTR, attr);
             }
             attr = attributes.get(name);
+            sslAttributesParsed = true;
         }
         return attr;
     }
@@ -981,7 +990,7 @@ public class Request
      * attributes and may also support additional attributes.
      */
     public Enumeration<String> getAttributeNames() {
-        if (isSecure()) {
+        if (isSecure() && !sslAttributesParsed) {
             getAttribute(Globals.CERTIFICATES_ATTR);
         }
         return new Enumerator<String>(attributes.keySet(), true);
index 582c88e..67e671b 100644 (file)
         by checking the <code>DirContext</code> or the cache. Test case based on
         a patch provided by Marc Guillemot. (markt)
       </fix>
+      <fix>
+        <bug>49613</bug>: Improve performance when using SSL for applications
+        that make multiple class to <code>Request.getAttributeNames()</code>.
+        Patch provided by Sampo Savolainen. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">