Author: kkolinko Date: Sun Jul 13 14:04:00 2014 New Revision: 1610199 URL: http://svn.apache.org/r1610199 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56658#c3 Fix regression that context reloads were broken. It is backport of r1610186.
Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/http/mapper/Mapper.java tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWebapps.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=1610199&r1=1610198&r2=1610199&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 Sun Jul 13 14:04:00 2014 @@ -292,6 +292,13 @@ public final class Mapper { new ContextVersion[contextVersions.length + 1]; if (insertMap(contextVersions, newContextVersions, newContextVersion)) { mappedContext.versions = newContextVersions; + } else { + // Re-registration after Context.reload() + // Replace ContextVersion with the new one + int pos = find(contextVersions, version); + if (pos >= 0 && contextVersions[pos].name.equals(version)) { + contextVersions[pos] = newContextVersion; + } } } } Modified: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWebapps.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWebapps.java?rev=1610199&r1=1610198&r2=1610199&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWebapps.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/http/mapper/TestMapperWebapps.java Sun Jul 13 14:04:00 2014 @@ -85,6 +85,52 @@ public class TestMapperWebapps extends T } @Test + public void testContextReload_Bug56658() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + File appDir = new File(getBuildDirectory(), "webapps/examples"); + // app dir is relative to server home + org.apache.catalina.Context ctxt = tomcat.addWebapp( + null, "/examples", appDir.getAbsolutePath()); + tomcat.start(); + + // The tests are from TestTomcat#testSingleWebapp(), #testJsps() + // We reload the context and verify that the pages are still accessible + ByteChunk res; + String text; + + res = getUrl("http://localhost:" + getPort() + + "/examples/servlets/servlet/HelloWorldExample"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<h1>Hello World!</h1>")); + + res = getUrl("http://localhost:" + getPort() + + "/examples/jsp/jsp2/el/basic-arithmetic.jsp"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<td>${(1==2) ? 3 : 4}</td>")); + + res = getUrl("http://localhost:" + getPort() + "/examples/index.html"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<title>Apache Tomcat Examples</title>")); + + ctxt.reload(); + + res = getUrl("http://localhost:" + getPort() + + "/examples/servlets/servlet/HelloWorldExample"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<h1>Hello World!</h1>")); + + res = getUrl("http://localhost:" + getPort() + + "/examples/jsp/jsp2/el/basic-arithmetic.jsp"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<td>${(1==2) ? 3 : 4}</td>")); + + res = getUrl("http://localhost:" + getPort() + "/examples/index.html"); + text = res.toString(); + Assert.assertTrue(text, text.contains("<title>Apache Tomcat Examples</title>")); + } + + @Test public void testWelcomeFileNotStrict() throws Exception { Tomcat tomcat = getTomcatInstance(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org