You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/03 20:07:25 UTC

svn commit: r1131126 - /tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java

Author: markt
Date: Fri Jun  3 18:07:24 2011
New Revision: 1131126

URL: http://svn.apache.org/viewvc?rev=1131126&view=rev
Log:
Fix TCK failure exposed by the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=51278
A previous change to ensure web.xml had precedence over fragments and annotations was not complete. It handled filter definitions and servlet definitions but not servlet mappings.

Modified:
    tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java

Modified: tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java?rev=1131126&r1=1131125&r2=1131126&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java Fri Jun  3 18:07:24 2011
@@ -1429,9 +1429,9 @@ public class WebXml {
         }
         errorPages.putAll(temp.getErrorPages());
 
-        // As per 'clarification' from the Servlet EG, filter mappings in the
+        // As per 'clarification' from the Servlet EG, filter definitions in the
         // main web.xml override those in fragments and those in fragments
-        // override mappings in annotations
+        // override those in annotations
         for (WebXml fragment : fragments) {
             Iterator<FilterMap> iterFilterMaps =
                 fragment.getFilterMappings().iterator();
@@ -1585,19 +1585,25 @@ public class WebXml {
         serviceRefs.putAll(temp.getServiceRefs());
         mergeInjectionFlags.clear();
 
-        // As per 'clarification' from the Servlet EG, servlet mappings in the
-        // main web.xml override those in fragments and those in fragments
-        // override mappings in annotations
+        // As per 'clarification' from the Servlet EG, servlet definitions and
+        // mappings in the main web.xml override those in fragments and those in
+        // fragments override those in annotations
+        // Remove servlet definitions and mappings from fragments that are
+        // defined in web.xml
         for (WebXml fragment : fragments) {
-            Iterator<Map.Entry<String,String>> iterServletMaps =
+            Iterator<Map.Entry<String,String>> iterFragmentServletMaps =
                 fragment.getServletMappings().entrySet().iterator();
-            while (iterServletMaps.hasNext()) {
-                Map.Entry<String,String> servletMap = iterServletMaps.next();
-                if (servletMappingNames.contains(servletMap.getValue())) {
-                    iterServletMaps.remove();
+            while (iterFragmentServletMaps.hasNext()) {
+                Map.Entry<String,String> servletMap =
+                    iterFragmentServletMaps.next();
+                if (servletMappingNames.contains(servletMap.getValue()) ||
+                        servletMappings.containsKey(servletMap.getKey())) {
+                    iterFragmentServletMaps.remove();
                 }
             }
         }
+        
+        // Add fragment mappings
         for (WebXml fragment : fragments) {
             for (Map.Entry<String,String> mapping :
                     fragment.getServletMappings().entrySet()) {



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