Author: kkolinko
Date: Mon Jun 23 19:13:27 2014
New Revision: 1604910
URL: http://svn.apache.org/r1604910
Log:
Simplify. No change in functionality.
This backports part of r1604066.
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=1604910&r1=1604909&r2=1604910&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:13:27 2014
@@ -662,35 +662,29 @@ public final class Mapper {
uri.setLimit(-1);
- Context[] contexts;
Context context = null;
ContextVersion contextVersion = null;
- int nesting = 0;
-
// Virtual host mapping
Host[] hosts = this.hosts;
- int pos = findIgnoreCase(hosts, host);
- if ((pos != -1) && (host.equalsIgnoreCase(hosts[pos].name))) {
- mappingData.host = hosts[pos].object;
- contexts = hosts[pos].contextList.contexts;
- nesting = hosts[pos].contextList.nesting;
- } else {
+ Host mappedHost = exactFindIgnoreCase(hosts, host);
+ if (mappedHost == null) {
if (defaultHostName == null) {
return;
}
- pos = find(hosts, defaultHostName);
- if ((pos != -1) && (defaultHostName.equals(hosts[pos].name))) {
- mappingData.host = hosts[pos].object;
- contexts = hosts[pos].contextList.contexts;
- nesting = hosts[pos].contextList.nesting;
- } else {
+ mappedHost = exactFind(hosts, defaultHostName);
+ if (mappedHost == null) {
return;
}
}
+ mappingData.host = mappedHost.object;
// Context mapping
- pos = find(contexts, uri);
+ ContextList contextList = mappedHost.contextList;
+ Context[] contexts = contextList.contexts;
+ int nesting = contextList.nesting;
+
+ int pos = find(contexts, uri);
if (pos == -1) {
return;
}
@@ -1270,6 +1264,24 @@ public final class Mapper {
return null;
}
+ /**
+ * Find a map element given its name in a sorted array of map elements.
This
+ * will return the element that you were searching for. Otherwise it will
+ * return <code>null</code>.
+ * @see #findIgnoreCase(MapElement[], CharChunk)
+ */
+ private static final <E extends MapElement> E exactFindIgnoreCase(E[] map,
+ CharChunk name) {
+ int pos = findIgnoreCase(map, name);
+ if (pos >= 0) {
+ E result = map[pos];
+ if (name.equalsIgnoreCase(result.name)) {
+ return result;
+ }
+ }
+ return null;
+ }
+
/**
* Compare given char chunk with String.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]