Author: schultz Date: Thu Aug 25 13:38:25 2011 New Revision: 1161566 URL: http://svn.apache.org/viewvc?rev=1161566&view=rev Log: Back-port of fix to bug #51866: JreMemoryLeakPreventionListener should protect against AWT thread creation - Added AWTThreadProtection setting
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java tomcat/tc6.0.x/trunk/webapps/docs/config/listeners.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1161566&r1=1161565&r2=1161566&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Thu Aug 25 13:38:25 2011 @@ -90,12 +90,6 @@ PATCHES PROPOSED TO BACKPORT: +1: markt -1: -* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51688 - JreMemoryLeakPreventionListener should protect against AWT thread creation - http://svn.apache.org/viewvc?view=revision&revision=1161303 - +1: schultz, kkolinko, markt - -1: - * Fix two typos in tomcat.nsi (uppercase vs. lowercase in a macro call and in a message) Already fixed in 5.5, 7.0, trunk. http://svn.apache.org/viewvc?rev=1161310&view=rev Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1161566&r1=1161565&r2=1161566&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Thu Aug 25 13:38:25 2011 @@ -66,6 +66,18 @@ public class JreMemoryLeakPreventionList public void setAppContextProtection(boolean appContextProtection) { this.appContextProtection = appContextProtection; } + + /** + * Protect against the memory leak caused when the first call to + * <code>java.awt.Toolkit.getDefaultToolkit()</code> is triggered + * by a web application. Defaults to <code>false</code> because a new + * Thread is launched. + */ + private boolean awtThreadProtection = false; + public boolean isAWTThreadProtection() { return awtThreadProtection; } + public void setAWTThreadProtection(boolean awtThreadProtection) { + this.awtThreadProtection = awtThreadProtection; + } /** * Protect against the memory leak caused when the first call to @@ -194,6 +206,12 @@ public class JreMemoryLeakPreventionList if (appContextProtection) { ImageIO.getCacheDirectory(); } + + // Trigger the creation of the AWT (AWT-Windows, AWT-XAWT, + // etc.) thread + if(awtThreadProtection) { + java.awt.Toolkit.getDefaultToolkit(); + } /* * Several components end up calling: Modified: tomcat/tc6.0.x/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/config/listeners.xml?rev=1161566&r1=1161565&r2=1161566&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/config/listeners.xml Thu Aug 25 13:38:25 2011 @@ -209,6 +209,13 @@ service:jmx:rmi://<hostname>:10002 should not be set when using this valve.</p> </attribute> + <attribute name="AWTThreadProtection" required="false"> + <p>Enables protection so that calls to + <code>java.awt.Toolkit.getDefaultToolkit()</code> triggered by a web + application do not result in a memory leak. + Defaults to <code>false</code> because an AWT thread is launched.</p> + </attribute> + <attribute name="rmiServerPortPlatform" required="true"> <p>The port to be used by the Platform JMX/RMI server.</p> </attribute> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org