Author: kkolinko
Date: Sun Jul 13 13:02:45 2014
New Revision: 1610186
URL: http://svn.apache.org/r1610186
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56658#c3
Fix regression that context reloads were broken.
Correct changelog entries.
Added:
tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java (with
props)
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=1610186&r1=1610185&r2=1610186&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mapper/Mapper.java Sun Jul 13
13:02:45 2014
@@ -278,6 +278,13 @@ public final class Mapper {
newContextVersion)) {
mappedContext.versions = newContextVersions;
contextObjectToContextVersionMap.put(context,
newContextVersion);
+ } 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;
+ }
}
}
}
Added: tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java?rev=1610186&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java (added)
+++ tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java Sun Jul
13 13:02:45 2014
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.mapper;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.startup.Tomcat;
+import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.websocket.server.WsContextListener;
+
+/**
+ * Mapper tests that use real web applications on a running Tomcat.
+ */
+public class TestMapperWebapps extends TomcatBaseTest{
+
+ @Test
+ public void testContextReload_56658() 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());
+ ctxt.addApplicationListener(WsContextListener.class.getName());
+ 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>"));
+ }
+}
Propchange: tomcat/trunk/test/org/apache/catalina/mapper/TestMapperWebapps.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1610186&r1=1610185&r2=1610186&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sun Jul 13 13:02:45 2014
@@ -45,6 +45,18 @@
issues to not "pop up" wrt. others).
-->
<section name="Tomcat 8.0.11 (markt)">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ <bug>56658</bug>: Fix regression that a context was inaccessible after
+ reload. (kkolinko)
+ </fix>
+ <fix>
+ <bug>56712</bug>: Fix session idle time calculations in
+ <code>PersistenceManager</code>. (kkolinko)
+ </fix>
+ </changelog>
+ </subsection>
<subsection name="Coyote">
<changelog>
<fix>
@@ -71,10 +83,6 @@
defined as <code>HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5</code> so
that no weak ciphers are enabled by default. (remm)
</fix>
- <fix>
- <bug>56712</bug>: Fix session idle time calculations in
- <code>PersistenceManager</code>. (kkolinko)
- </fix>
</changelog>
</subsection>
<subsection name="Jasper">
@@ -86,7 +94,7 @@
</changelog>
</subsection>
</section>
-<section name="Tomcat 8.0.10 (markt)">
+<section name="Tomcat 8.0.10 (markt)" rtext="not released">
<subsection name="Catalina">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]