Author: kkolinko Date: Mon Jun 23 19:47:57 2014 New Revision: 1604917 URL: http://svn.apache.org/r1604917 Log: Simplify. If there is only one version available, use it and skip exactFind(version) call.
Also skip "if (contextVersion != null)" check before internalMapWrapper() call, as "contextVersion.object" dereference should have thrown an NPE in that case. This completes backport of r1604437. Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java?rev=1604917&r1=1604916&r2=1604917&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java Mon Jun 23 19:47:57 2014 @@ -726,7 +726,7 @@ public final class Mapper { mappingData.contextPath.setString(context.name); - ContextVersion contextVersion; + ContextVersion contextVersion = null; ContextVersion[] contextVersions = context.versions; int versionCount = contextVersions.length; if (versionCount > 1) { @@ -735,27 +735,20 @@ public final class Mapper { contextObjects[i] = contextVersions[i].object; } mappingData.contexts = contextObjects; + if (version != null) { + contextVersion = exactFind(contextVersions, version); + } } - - if (version == null) { + if (contextVersion == null) { // Return the latest version contextVersion = contextVersions[versionCount - 1]; - } else { - pos = find(contextVersions, version); - if (pos < 0 || !contextVersions[pos].name.equals(version)) { - // Return the latest version - contextVersion = contextVersions[versionCount - 1]; - } else { - contextVersion = contextVersions[pos]; - } } + mappingData.context = contextVersion.object; mappingData.contextSlashCount = contextVersion.slashCount; // Wrapper mapping - if (contextVersion != null) { - internalMapWrapper(contextVersion, uri, mappingData); - } + internalMapWrapper(contextVersion, uri, mappingData); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org