From d48ee4f3f7889907fcc3c7d85950dce1eb075bf8 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 3 Jun 2011 18:07:24 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1131126 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/deploy/WebXml.java | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/java/org/apache/catalina/deploy/WebXml.java b/java/org/apache/catalina/deploy/WebXml.java index 99ec9910f..4ddc3084a 100644 --- a/java/org/apache/catalina/deploy/WebXml.java +++ b/java/org/apache/catalina/deploy/WebXml.java @@ -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 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> iterServletMaps = + Iterator> iterFragmentServletMaps = fragment.getServletMappings().entrySet().iterator(); - while (iterServletMaps.hasNext()) { - Map.Entry servletMap = iterServletMaps.next(); - if (servletMappingNames.contains(servletMap.getValue())) { - iterServletMaps.remove(); + while (iterFragmentServletMaps.hasNext()) { + Map.Entry servletMap = + iterFragmentServletMaps.next(); + if (servletMappingNames.contains(servletMap.getValue()) || + servletMappings.containsKey(servletMap.getKey())) { + iterFragmentServletMaps.remove(); } } } + + // Add fragment mappings for (WebXml fragment : fragments) { for (Map.Entry mapping : fragment.getServletMappings().entrySet()) { -- 2.11.0