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 00:17:20 UTC

svn commit: r1604661 - in /tomcat/trunk: java/org/apache/catalina/connector/CoyoteAdapter.java webapps/docs/changelog.xml

Author: kkolinko
Date: Sun Jun 22 22:17:20 2014
New Revision: 1604661

URL: http://svn.apache.org/r1604661
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56657#c2
Ensure that re-mapping selects the context version that we expect.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java?rev=1604661&r1=1604660&r2=1604661&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/CoyoteAdapter.java Sun Jun 22 22:17:20 2014
@@ -850,14 +850,13 @@ public class CoyoteAdapter implements Ad
             request.getMappingData().recycle();
         }
 
-        boolean mapRequired = true;
+        // Version for the second mapping loop and
+        // Context that we expect to get for that version
         String version = null;
+        Context versionContext = null;
+        boolean mapRequired = true;
 
         while (mapRequired) {
-            if (version != null) {
-                // Once we have a version - that is it
-                mapRequired = false;
-            }
             // This will map the the latest version by default
             connector.getService().getMapper().map(serverName, decodedURI,
                     version, request.getMappingData());
@@ -899,8 +898,13 @@ public class CoyoteAdapter implements Ad
 
             sessionID = request.getRequestedSessionId();
 
-            if (mapRequired) {
-                mapRequired = false;
+            mapRequired = false;
+            if (version != null && request.getContext() == versionContext) {
+                // We got the version that we asked for. That is it.
+            } else {
+                version = null;
+                versionContext = null;
+
                 Context[] contexts = request.getMappingData().contexts;
                 // Single contextVersion means no need to remap
                 // No session ID means no possibility of remap
@@ -909,11 +913,13 @@ public class CoyoteAdapter implements Ad
                     for (int i = (contexts.length); i > 0; i--) {
                         Context ctxt = contexts[i - 1];
                         if (ctxt.getManager().findSession(sessionID) != null) {
-                            // We found a context. Is it the one that has already been mapped?
+                            // We found a context. Is it the one that has
+                            // already been mapped?
                             if (!ctxt.equals(request.getMappingData().context)) {
-                                // Set version so second time through mapping the
-                                // correct context is found
+                                // Set version so second time through mapping
+                                // the correct context is found
                                 version = ctxt.getWebappVersion();
+                                versionContext = ctxt;
                                 // Reset mapping
                                 request.getMappingData().recycle();
                                 mapRequired = true;
@@ -923,6 +929,7 @@ public class CoyoteAdapter implements Ad
                     }
                 }
             }
+
             if (!mapRequired && request.getContext().getPaused()) {
                 // Found a matching context but it is paused. Mapping data will
                 // be wrong since some Wrappers may not be registered at this

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1604661&r1=1604660&r2=1604661&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sun Jun 22 22:17:20 2014
@@ -69,7 +69,8 @@
       <fix>
         <bug>56657</bug>: When using parallel deployment, if the same session id
         matches different versions of a web application, prefer the latest
-        version. (kkolinko)
+        version. Ensure that remapping selects the version that we expect.
+        (kkolinko)
       </fix>
       <fix>
         Assert that mapping result object is empty before performing mapping



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org