From: markt Date: Thu, 22 Jul 2010 14:36:15 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49613 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f6f2b87c3cd2c1286f7c2398c92d1f550e765fe4;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49613 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 --- diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java index 14ea7a019..728923505 100644 --- a/java/org/apache/catalina/connector/Request.java +++ b/java/org/apache/catalina/connector/Request.java @@ -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 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 getAttributeNames() { - if (isSecure()) { + if (isSecure() && !sslAttributesParsed) { getAttribute(Globals.CERTIFICATES_ATTR); } return new Enumerator(attributes.keySet(), true); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 582c88ef0..67e671b0e 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -184,6 +184,11 @@ by checking the DirContext or the cache. Test case based on a patch provided by Marc Guillemot. (markt) + + 49613: Improve performance when using SSL for applications + that make multiple class to Request.getAttributeNames(). + Patch provided by Sampo Savolainen. (markt) +