You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2014/06/23 09:55:05 UTC
svn commit: r1604708 -
/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java
Author: kkolinko
Date: Mon Jun 23 07:55:04 2014
New Revision: 1604708
URL: http://svn.apache.org/r1604708
Log:
Simplify addContextVersion.
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=1604708&r1=1604707&r2=1604708&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 07:55:04 2014
@@ -206,51 +206,44 @@ public final class Mapper {
String version, Object context, String[] welcomeResources,
javax.naming.Context resources) {
- Host[] hosts = this.hosts;
- int pos = find(hosts, hostName);
- if( pos <0 ) {
+ Host mappedHost = exactFind(hosts, hostName);
+ if (mappedHost == null) {
addHost(hostName, new String[0], host);
- hosts = this.hosts;
- pos = find(hosts, hostName);
- }
- if (pos < 0) {
- log.error("No host found: " + hostName);
+ mappedHost = exactFind(hosts, hostName);
+ if (mappedHost == null) {
+ log.error("No host found: " + hostName);
+ return;
+ }
}
- Host mappedHost = hosts[pos];
- if (mappedHost.name.equals(hostName)) {
- int slashCount = slashCount(path);
- synchronized (mappedHost) {
- Context[] contexts = mappedHost.contextList.contexts;
- // Update nesting
- if (slashCount > mappedHost.contextList.nesting) {
- mappedHost.contextList.nesting = slashCount;
- }
- int pos2 = find(contexts, path);
- if (pos2 < 0 || !path.equals(contexts[pos2].name)) {
- Context newContext = new Context();
- newContext.name = path;
- Context[] newContexts = new Context[contexts.length + 1];
- if (insertMap(contexts, newContexts, newContext)) {
- mappedHost.contextList.contexts = newContexts;
- }
- pos2 = find(newContexts, path);
+ int slashCount = slashCount(path);
+ synchronized (mappedHost) {
+ Context[] contexts = mappedHost.contextList.contexts;
+ // Update nesting
+ if (slashCount > mappedHost.contextList.nesting) {
+ mappedHost.contextList.nesting = slashCount;
+ }
+ Context mappedContext = exactFind(contexts, path);
+ if (mappedContext == null) {
+ mappedContext = new Context();
+ mappedContext.name = path;
+ Context[] newContexts = new Context[contexts.length + 1];
+ if (insertMap(contexts, newContexts, mappedContext)) {
+ mappedHost.contextList.contexts = newContexts;
}
+ }
- Context mappedContext = mappedHost.contextList.contexts[pos2];
-
- ContextVersion[] contextVersions = mappedContext.versions;
- ContextVersion[] newContextVersions =
- new ContextVersion[contextVersions.length + 1];
- ContextVersion newContextVersion = new ContextVersion();
- newContextVersion.path = path;
- newContextVersion.slashCount = slashCount;
- newContextVersion.name = version;
- newContextVersion.object = context;
- newContextVersion.welcomeResources = welcomeResources;
- newContextVersion.resources = resources;
- if (insertMap(contextVersions, newContextVersions, newContextVersion)) {
- mappedContext.versions = newContextVersions;
- }
+ ContextVersion[] contextVersions = mappedContext.versions;
+ ContextVersion[] newContextVersions =
+ new ContextVersion[contextVersions.length + 1];
+ ContextVersion newContextVersion = new ContextVersion();
+ newContextVersion.path = path;
+ newContextVersion.slashCount = slashCount;
+ newContextVersion.name = version;
+ newContextVersion.object = context;
+ newContextVersion.welcomeResources = welcomeResources;
+ newContextVersion.resources = resources;
+ if (insertMap(contextVersions, newContextVersions, newContextVersion)) {
+ mappedContext.versions = newContextVersions;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org