From: markt Date: Wed, 8 Jun 2011 00:44:14 +0000 (+0000) Subject: Fix regression in welcome file processing X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4a547e8a1e979ac404ca8a6d1c586797dec7c404;p=tomcat7.0 Fix regression in welcome file processing git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1133221 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/deploy/WebXml.java b/java/org/apache/catalina/deploy/WebXml.java index 4ddc3084a..a2ecbb61e 100644 --- a/java/org/apache/catalina/deploy/WebXml.java +++ b/java/org/apache/catalina/deploy/WebXml.java @@ -346,13 +346,25 @@ public class WebXml { } public Map getMimeMappings() { return mimeMappings; } - // welcome-file-list - // When merging web.xml files it may be necessary for any new welcome files - // to completely replace the current set + // welcome-file-list merge control private boolean replaceWelcomeFiles = false; + private boolean alwaysAddWelcomeFiles = true; + /** + * When merging/parsing web.xml files into this web.xml should the current + * set be completely replaced? + */ public void setReplaceWelcomeFiles(boolean replaceWelcomeFiles) { this.replaceWelcomeFiles = replaceWelcomeFiles; } + /** + * When merging from this web.xml, should the welcome files be added to the + * target web.xml even if it already contains welcome file definitions. + */ + public void setAlwaysAddWelcomeFiles(boolean alwaysAddWelcomeFiles) { + this.alwaysAddWelcomeFiles = alwaysAddWelcomeFiles; + } + + // welcome-file-list private Set welcomeFiles = new LinkedHashSet(); public void addWelcomeFile(String welcomeFile) { if (replaceWelcomeFiles) { @@ -1322,7 +1334,16 @@ public class WebXml { // Context doesn't use version directly for (String welcomeFile : welcomeFiles) { - context.addWelcomeFile(welcomeFile); + /* + * The following will result in a welcome file of "" so don't add + * that to the context + * + * + * + */ + if (welcomeFile != null && welcomeFile.length() > 0) { + context.addWelcomeFile(welcomeFile); + } } // Do this last as it depends on servlets @@ -1848,9 +1869,10 @@ public class WebXml { taglibs.putAll(temp.getTaglibs()); for (WebXml fragment : fragments) { - for (String welcomeFile : fragment.getWelcomeFiles()) { - // Always additive - addWelcomeFile(welcomeFile); + if (fragment.alwaysAddWelcomeFiles || welcomeFiles.size() == 0) { + for (String welcomeFile : fragment.getWelcomeFiles()) { + addWelcomeFile(welcomeFile); + } } } diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index 140329f4a..adecb5f49 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -1199,6 +1199,9 @@ public class ContextConfig // distributable when the default fragment is merged with the main // web.xml webXmlDefaultFragment.setDistributable(true); + // When merging, the default welcome files are only used if the app has + // not defined any welcomes files. + webXmlDefaultFragment.setAlwaysAddWelcomeFiles(false); // Parse global web.xml if present InputSource globalWebXml = getGlobalWebXmlSource(); @@ -1211,7 +1214,7 @@ public class ContextConfig // Parse host level web.xml if present // Additive apart from welcome pages - webXml.setReplaceWelcomeFiles(true); + webXmlDefaultFragment.setReplaceWelcomeFiles(true); InputSource hostWebXml = getHostWebXmlSource(); parseWebXml(hostWebXml, webXmlDefaultFragment, false); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 485dd5421..39db3c899 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -60,6 +60,10 @@ web application from being marked as distributable. (kfujino/mark) + Correct a regression in the fix for 51278 that prevented a + web application from overriding the default welcome files. (mark) + + Enable remaining valves for Servlet 3 asynchronous processing support. (markt)