Author: markt Date: Thu Jan 9 14:14:24 2014 New Revision: 1556808 URL: http://svn.apache.org/r1556808 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55958 Differentiate between foo.war the directory and foo.war the file
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ContextName.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/util/TestContextName.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1556807 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Thu Jan 9 14:14:24 2014 @@ -488,7 +488,7 @@ public class FarmWarDeployer extends Clu public void fileModified(File newWar) { try { File deployWar = new File(getDeployDirFile(), newWar.getName()); - ContextName cn = new ContextName(deployWar.getName()); + ContextName cn = new ContextName(deployWar.getName(), true); if (deployWar.exists() && deployWar.lastModified() > newWar.lastModified()) { if (log.isInfoEnabled()) log.info(sm.getString("farmWarDeployer.alreadyDeployed", cn.getName())); @@ -524,7 +524,7 @@ public class FarmWarDeployer extends Clu @Override public void fileRemoved(File removeWar) { try { - ContextName cn = new ContextName(removeWar.getName()); + ContextName cn = new ContextName(removeWar.getName(), true); if (log.isInfoEnabled()) log.info(sm.getString("farmWarDeployer.removeLocal", cn.getName())); Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/manager/HTMLManagerServlet.java Thu Jan 9 14:14:24 2014 @@ -285,7 +285,7 @@ public final class HTMLManagerServlet ex break; } - ContextName cn = new ContextName(filename); + ContextName cn = new ContextName(filename, true); String name = cn.getName(); if ((host.findChild(name) != null) && !isDeployed(name)) { Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java Thu Jan 9 14:14:24 2014 @@ -509,7 +509,7 @@ public class MBeanUtils { ObjectName name = null; Host host = (Host)context.getParent(); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); name = new ObjectName(domain + ":j2eeType=WebModule,name=//" + host.getName()+ cn.getDisplayName() + ",J2EEApplication=none,J2EEServer=none"); @@ -540,7 +540,7 @@ public class MBeanUtils { ",resourcetype=Global,name=" + environment.getName()); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=Environment" + ",resourcetype=Context,context=" + cn.getDisplayName() + @@ -575,7 +575,7 @@ public class MBeanUtils { ",name=" + quotedResourceName); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=Resource" + ",resourcetype=Context,context=" + cn.getDisplayName() + @@ -613,7 +613,7 @@ public class MBeanUtils { ",name=" + quotedResourceLinkName); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=ResourceLink" + ",resourcetype=Context,context=" + cn.getDisplayName() + @@ -715,7 +715,7 @@ public class MBeanUtils { container.getName()); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=Loader,context=" + cn.getDisplayName() + ",host=" + host.getName()); @@ -751,7 +751,7 @@ public class MBeanUtils { container.getName()); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=Manager,context=" + cn.getDisplayName() + ",host=" + host.getName()); @@ -784,7 +784,7 @@ public class MBeanUtils { ",resourcetype=Global"); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=NamingResources" + ",resourcetype=Context,context=" + cn.getDisplayName() + @@ -842,7 +842,7 @@ public class MBeanUtils { container.getName()); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); name = new ObjectName(domain + ":type=Realm,context=" + cn.getDisplayName() + ",host=" + host.getName()); @@ -1015,7 +1015,7 @@ public class MBeanUtils { ext + local ); } else if (container instanceof Context) { Context context = ((Context)container); - ContextName cn = new ContextName(context.getName()); + ContextName cn = new ContextName(context.getName(), false); Container host = context.getParent(); String local=",context=" + cn.getDisplayName() + ",host=" + host.getName(); @@ -1750,7 +1750,7 @@ public class MBeanUtils { keyProperties.append(c.getName()); } else if (c instanceof Context) { keyProperties.append(",context="); - ContextName cn = new ContextName(c.getName()); + ContextName cn = new ContextName(c.getName(), false); keyProperties.append(cn.getDisplayName()); } else if (c instanceof Host) { keyProperties.append(",host="); Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java Thu Jan 9 14:14:24 2014 @@ -535,7 +535,7 @@ public class HostConfig File appBase = appBase(); File configBase = configBase(); - ContextName cn = new ContextName(name); + ContextName cn = new ContextName(name, false); String baseName = cn.getBaseName(); if (deploymentExists(baseName)) { @@ -576,7 +576,7 @@ public class HostConfig File contextXml = new File(configBase, files[i]); if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".xml")) { - ContextName cn = new ContextName(files[i]); + ContextName cn = new ContextName(files[i], true); if (isServiced(cn.getName()) || deploymentExists(cn.getName())) continue; @@ -769,7 +769,7 @@ public class HostConfig if (files[i].toLowerCase(Locale.ENGLISH).endsWith(".war") && war.isFile() && !invalidWars.contains(files[i]) ) { - ContextName cn = new ContextName(files[i]); + ContextName cn = new ContextName(files[i], true); if (isServiced(cn.getName())) { continue; @@ -1122,7 +1122,7 @@ public class HostConfig continue; File dir = new File(appBase, files[i]); if (dir.isDirectory()) { - ContextName cn = new ContextName(files[i]); + ContextName cn = new ContextName(files[i], false); if (isServiced(cn.getName()) || deploymentExists(cn.getName())) continue; @@ -1663,9 +1663,9 @@ public class HostConfig } Iterator<String> iter = sortedAppNames.iterator(); - ContextName previous = new ContextName(iter.next()); + ContextName previous = new ContextName(iter.next(), false); do { - ContextName current = new ContextName(iter.next()); + ContextName current = new ContextName(iter.next(), false); if (current.getPath().equals(previous.getPath())) { // Current and previous are same path - current will always Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ContextName.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ContextName.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ContextName.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/ContextName.java Thu Jan 9 14:14:24 2014 @@ -37,8 +37,25 @@ public final class ContextName { * directory name, WAR name or context.xml name. * * @param name The name to use as the basis for this object + * + * @deprecated Use {@link ContextName#ContextName(String, boolean)} */ + @Deprecated public ContextName(String name) { + this(name, true); + } + + + /** + * Creates an instance from a context name, display name, base name, + * directory name, WAR name or context.xml name. + * + * @param name The name to use as the basis for this object + * @param stripFileExtension If a .war or .xml file extension is present + * at the end of the provided name should it be + * removed? + */ + public ContextName(String name, boolean stripFileExtension) { String tmp1 = name; @@ -58,8 +75,9 @@ public final class ContextName { } // Remove any file extensions - if (tmp1.toLowerCase(Locale.ENGLISH).endsWith(".war") || - tmp1.toLowerCase(Locale.ENGLISH).endsWith(".xml")) { + if (stripFileExtension && + (tmp1.toLowerCase(Locale.ENGLISH).endsWith(".war") || + tmp1.toLowerCase(Locale.ENGLISH).endsWith(".xml"))) { tmp1 = tmp1.substring(0, tmp1.length() -4); } Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Thu Jan 9 14:14:24 2014 @@ -45,7 +45,7 @@ import org.apache.tomcat.util.buf.B2CCon */ public class TestHostConfigAutomaticDeployment extends TomcatBaseTest { - private static final ContextName APP_NAME = new ContextName("myapp"); + private static final ContextName APP_NAME = new ContextName("myapp", false); private static final File XML_SOURCE = new File("test/deployment/context.xml"); private static final File WAR_XML_SOURCE = Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/util/TestContextName.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/util/TestContextName.java?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/util/TestContextName.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/util/TestContextName.java Thu Jan 9 14:14:24 2014 @@ -44,6 +44,8 @@ public class TestContextName { private ContextName cn18; private ContextName cn19; private ContextName cn20; + private ContextName cn21; + private ContextName cn22; @Before public void setUp() throws Exception { @@ -57,16 +59,18 @@ public class TestContextName { cn8 = new ContextName("/", "C"); cn9 = new ContextName("/foo", "D"); cn10 = new ContextName("/foo/bar", "E"); - cn11 = new ContextName("ROOT"); - cn12 = new ContextName("foo"); - cn13 = new ContextName("foo#bar"); - cn14 = new ContextName("ROOT##A"); - cn15 = new ContextName("foo##D"); - cn16 = new ContextName("foo#bar##E"); + cn11 = new ContextName("ROOT", false); + cn12 = new ContextName("foo", false); + cn13 = new ContextName("foo#bar", false); + cn14 = new ContextName("ROOT##A", false); + cn15 = new ContextName("foo##D", false); + cn16 = new ContextName("foo#bar##E", false); cn17 = new ContextName("/ROOT", null); - cn18 = new ContextName("/ROOT#bar"); - cn19 = new ContextName("/ROOT#bar##A"); - cn20 = new ContextName("/ROOT##A"); + cn18 = new ContextName("/ROOT#bar", false); + cn19 = new ContextName("/ROOT#bar##A", false); + cn20 = new ContextName("/ROOT##A", false); + cn21 = new ContextName("foo.war", false); + cn22 = new ContextName("foo.war", true); } @Test @@ -91,6 +95,8 @@ public class TestContextName { assertEquals("ROOT#bar", cn18.getBaseName()); assertEquals("ROOT#bar##A", cn19.getBaseName()); assertEquals("ROOT##A", cn20.getBaseName()); + assertEquals("foo.war", cn21.getBaseName()); + assertEquals("foo", cn22.getBaseName()); } @Test @@ -115,6 +121,8 @@ public class TestContextName { assertEquals("/ROOT/bar", cn18.getPath()); assertEquals("/ROOT/bar", cn19.getPath()); assertEquals("", cn20.getPath()); + assertEquals("/foo.war", cn21.getPath()); + assertEquals("/foo", cn22.getPath()); } @Test @@ -139,6 +147,8 @@ public class TestContextName { assertEquals("", cn18.getVersion()); assertEquals("A", cn19.getVersion()); assertEquals("A", cn20.getVersion()); + assertEquals("", cn21.getVersion()); + assertEquals("", cn22.getVersion()); } @Test @@ -163,6 +173,8 @@ public class TestContextName { assertEquals("/ROOT/bar", cn18.getName()); assertEquals("/ROOT/bar##A", cn19.getName()); assertEquals("##A", cn20.getName()); + assertEquals("/foo.war", cn21.getName()); + assertEquals("/foo", cn22.getName()); } @Test @@ -187,6 +199,8 @@ public class TestContextName { assertEquals("/ROOT/bar", cn18.getDisplayName()); assertEquals("/ROOT/bar##A", cn19.getDisplayName()); assertEquals("/##A", cn20.getDisplayName()); + assertEquals("/foo.war", cn21.getDisplayName()); + assertEquals("/foo", cn22.getDisplayName()); } @Test @@ -211,12 +225,14 @@ public class TestContextName { doTestConstructorString(cn18); doTestConstructorString(cn19); doTestConstructorString(cn20); + doTestConstructorString(cn21); + doTestConstructorString(cn22); } private void doTestConstructorString(ContextName src) { - doCompare(src, new ContextName(src.getBaseName())); - doCompare(src, new ContextName(src.getDisplayName())); - doCompare(src, new ContextName(src.getName())); + doCompare(src, new ContextName(src.getBaseName(), false)); + doCompare(src, new ContextName(src.getDisplayName(), false)); + doCompare(src, new ContextName(src.getName(), false)); } private void doCompare(ContextName cn1, ContextName cn2) { Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1556808&r1=1556807&r2=1556808&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Thu Jan 9 14:14:24 2014 @@ -66,6 +66,10 @@ <bug>55937</bug>: When deploying applications, treat a context path of <code>/ROOT</code> as equivalent to <code>/</code>. (markt) </fix> + <fix> + <bug>55958</bug>: Differentiate between <code>foo.war</code> the WAR + file and <code>foo.war</code> the directory. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org