Author: markt
Date: Fri Nov 30 20:52:26 2018
New Revision: 1847853
URL: http://svn.apache.org/viewvc?rev=1847853&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62968
Avoid unnecessary (and relatively expensive) <code>getResources()</code> call
in the Mapper when processing rule 7.
Modified:
tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java?rev=1847853&r1=1847852&r2=1847853&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java Fri Nov 30
20:52:26 2018
@@ -1028,22 +1028,28 @@ public final class Mapper {
char[] buf = path.getBuffer();
if (contextVersion.resources != null && buf[pathEnd -1 ] != '/') {
String pathStr = path.toString();
- WebResource file;
- // Handle context root
- if (pathStr.length() == 0) {
- file = contextVersion.resources.getResource("/");
- } else {
- file = contextVersion.resources.getResource(pathStr);
- }
- if (file != null && file.isDirectory() &&
-
contextVersion.object.getMapperDirectoryRedirectEnabled()) {
- // Note: this mutates the path: do not do any processing
- // after this (since we set the redirectPath, there
- // shouldn't be any)
- path.setOffset(pathOffset);
- path.append('/');
- mappingData.redirectPath.setChars
- (path.getBuffer(), path.getStart(), path.getLength());
+ // Note: Check redirect first to save unnecessary getResource()
+ // call. See BZ 62968.
+ if (contextVersion.object.getMapperDirectoryRedirectEnabled())
{
+ WebResource file;
+ // Handle context root
+ if (pathStr.length() == 0) {
+ file = contextVersion.resources.getResource("/");
+ } else {
+ file = contextVersion.resources.getResource(pathStr);
+ }
+ if (file != null && file.isDirectory()) {
+ // Note: this mutates the path: do not do any
processing
+ // after this (since we set the redirectPath, there
+ // shouldn't be any)
+ path.setOffset(pathOffset);
+ path.append('/');
+ mappingData.redirectPath.setChars
+ (path.getBuffer(), path.getStart(),
path.getLength());
+ } else {
+ mappingData.requestPath.setString(pathStr);
+ mappingData.wrapperPath.setString(pathStr);
+ }
} else {
mappingData.requestPath.setString(pathStr);
mappingData.wrapperPath.setString(pathStr);
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1847853&r1=1847852&r2=1847853&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Nov 30 20:52:26 2018
@@ -106,6 +106,11 @@
Add periodic event notification for lifecycle listeners configured on
the Server. (remm)
</update>
+ <fix>
+ <bug>62968</bug>: Avoid unnecessary (and relatively expensive)
+ <code>getResources()</code> call in the Mapper when processing rule 7.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]