Author: schultz Date: Fri Aug 19 16:23:44 2011 New Revision: 1159673 URL: http://svn.apache.org/viewvc?rev=1159673&view=rev Log: Fixed bug 51688: JreMemoryLeakPreventionListener should protect against AWT thread creation - Added awtThreadProtection setting
Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1159673&r1=1159672&r2=1159673&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Fri Aug 19 16:23:44 2011 @@ -67,6 +67,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 @@ -218,6 +230,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/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1159673&r1=1159672&r2=1159673&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Aug 19 16:23:44 2011 @@ -89,6 +89,10 @@ <bug>51658</bug>: Fix possible NPE when logging a failed request. Based on a suggestion by Felix Schumacher. (markt) </fix> + <fix> + <bug>51688</bug> JreMemoryLeakPreventionListener now protects against + AWT thread creation. (schultz) + </fix> </changelog> </subsection> <subsection name="Coyote"> Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml?rev=1159673&r1=1159672&r2=1159673&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml Fri Aug 19 16:23:44 2011 @@ -173,6 +173,12 @@ it is strongly recommended that this protection is enabled. The default is <code>true</code>.</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="driverManagerProtection" required="false"> <p>The first use of <code>java.sql.DriverManager</code> will trigger the --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org