This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new df150a2ddf BZ 69419 - further performance improvements df150a2ddf is described below commit df150a2ddf9e00bbed77e6b035f63caf3fe77d7a Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Nov 4 15:43:50 2024 +0000 BZ 69419 - further performance improvements --- .../apache/catalina/core/ApplicationHttpRequest.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java index ef9f89761f..a176e6db7b 100644 --- a/java/org/apache/catalina/core/ApplicationHttpRequest.java +++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java @@ -189,6 +189,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { protected final Object[] specialAttributes = new Object[specials.length]; + /* + * Used to speed up getAttribute(). See that method for details. + */ + private ApplicationHttpRequest wrappedApplicationHttpRequest; + /** * Construct a new wrapped request around the specified servlet request. * @@ -241,11 +246,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { * the first wrapped request that isn't an instance of ApplicationHttpRequest before calling getAttribute() * to avoid a call to getSpecial() for each nested ApplicationHttpRequest. */ - ServletRequest wrappedRequest = getRequest(); - while (wrappedRequest instanceof ApplicationHttpRequest) { - wrappedRequest = ((ApplicationHttpRequest) wrappedRequest).getRequest(); + ApplicationHttpRequest request = this; + while (request.wrappedApplicationHttpRequest != null) { + request = request.wrappedApplicationHttpRequest; } - return wrappedRequest.getAttribute(name); + return request.getRequest().getAttribute(name); } else { if ((specialAttributes[pos] == null) && (specialAttributes[SPECIALS_FIRST_FORWARD_INDEX] == null) && (pos >= SPECIALS_FIRST_FORWARD_INDEX)) { @@ -676,6 +681,13 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper { super.setRequest(request); + // Type specific version of the wrapped request to speed up getAttribute() + if (request instanceof ApplicationHttpRequest) { + wrappedApplicationHttpRequest = (ApplicationHttpRequest) request; + } else { + wrappedApplicationHttpRequest = null; + } + // Initialize the attributes for this request dispatcherType = (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR); requestDispatcherPath = request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org