Author: markt Date: Mon Nov 12 01:26:59 2012 New Revision: 1408166 URL: http://svn.apache.org/viewvc?rev=1408166&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54007 Fix memory leak that prevents context.xml files associated with failed deployments from being deleted. Fix errors uncovered once the above issue was resolved.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/FailedContext.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/HostConfig.java tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/LifecycleBase.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1408163-1408165 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1408166&r1=1408165&r2=1408166&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java Mon Nov 12 01:26:59 2012 @@ -1094,9 +1094,12 @@ public class ContextConfig implements Li } // Changed to getWorkPath per Bugzilla 35819. - String workDir = ((StandardContext) context).getWorkPath(); - if (workDir != null) - ExpandWar.delete(new File(workDir)); + if (context instanceof StandardContext) { + String workDir = ((StandardContext) context).getWorkPath(); + if (workDir != null) { + ExpandWar.delete(new File(workDir)); + } + } } Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/FailedContext.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/FailedContext.java?rev=1408166&r1=1408165&r2=1408166&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/FailedContext.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/FailedContext.java Mon Nov 12 01:26:59 2012 @@ -181,6 +181,10 @@ public class FailedContext extends Lifec @Override public void removeChild(Container child) { /* NO-OP */ } + @Override + public String toString() { + return getName(); + } // -------------------------------------------- All NO-OPs beyond this point @Override 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=1408166&r1=1408165&r2=1408166&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 Mon Nov 12 01:26:59 2012 @@ -603,10 +603,12 @@ public class HostConfig boolean isExternalWar = false; boolean isExternal = false; File expandedDocBase = null; + FileInputStream fis = null; try { + fis = new FileInputStream(contextXml); synchronized (digester) { try { - context = (Context) digester.parse(contextXml); + context = (Context) digester.parse(fis); } catch (Exception e) { log.error(sm.getString( "hostConfig.deployDescriptor.error", @@ -658,6 +660,13 @@ public class HostConfig log.error(sm.getString("hostConfig.deployDescriptor.error", contextXml.getAbsolutePath()), t); } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + // Ignore + } + } // Get paths for WAR and expanded WAR in appBase // default to appBase dir + name Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/LifecycleBase.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/LifecycleBase.java?rev=1408166&r1=1408165&r2=1408166&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/LifecycleBase.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/util/LifecycleBase.java Mon Nov 12 01:26:59 2012 @@ -242,7 +242,7 @@ public abstract class LifecycleBase impl setStateInternal(LifecycleState.STOPPED, null, false); destroy(); - } else { + } else if (!state.equals(LifecycleState.FAILED)){ // Shouldn't be necessary but acts as a check that sub-classes are // doing what they are supposed to. if (!state.equals(LifecycleState.STOPPING)) { @@ -272,7 +272,8 @@ public abstract class LifecycleBase impl stop(); } catch (LifecycleException e) { // Just log. Still want to destroy. - log.warn(sm.getString("lifecycleBase.destroyStopFail"), e); + log.warn(sm.getString( + "lifecycleBase.destroyStopFail", toString()), e); } } 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=1408166&r1=1408165&r2=1408166&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Nov 12 01:26:59 2012 @@ -73,6 +73,12 @@ Apache web server. (markt) </add> <fix> + <bug>54007</bug>: Fix a memory leak that prevented deletion of a + context.xml file associated with a Context that had failed to deploy. + Also fix the problems uncovered with undeploying such a Context once the + leak had been fixed and the file could be deleted. (markt) + </fix> + <fix> <bug>54044</bug>: Correct bug in timestamp cache used by logging (including the access log valve) that meant entries could be made with an earlier timestamp than the true timestamp. (markt) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org