Author: markt Date: Mon Jun 24 15:33:33 2013 New Revision: 1496098 URL: http://svn.apache.org/r1496098 Log: Changes to java.beans.Introspector#flushCaches() mean that AppContext protection is not required from 1.7.0_02 onwards. Changes to AppContext meant the memory leak protection required a graphical environment from 1.7.0_25 onwards.
Modified: tomcat/tc7.0.x/trunk/ (props changed) 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 Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1496061 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=1496098&r1=1496097&r2=1496098&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 Mon Jun 24 15:33:33 2013 @@ -59,12 +59,30 @@ public class JreMemoryLeakPreventionList private static final StringManager sm = StringManager.getManager(Constants.Package); + private static final boolean IS_JAVA_7_OR_LATER; + + static { + boolean isJava7OrLater; + try { + Class.forName("java.util.Objects"); + isJava7OrLater = true; + } catch (ClassNotFoundException e) { + isJava7OrLater = false; + } + IS_JAVA_7_OR_LATER = isJava7OrLater; + } + /** * Protect against the memory leak caused when the first call to * <code>sun.awt.AppContext.getAppContext()</code> is triggered by a web - * application. Defaults to <code>true</code>. + * application. Defaults to <code>true</code> for Java 6 and earlier (since + * it is used by {@link java.beans.Introspector#flushCaches()}) but defaults + * to <code>false</code> for Java 7 and later since + * {@link java.beans.Introspector#flushCaches()} no longer uses AppContext + * from 1.7.0_02 onwards. Also, from 1.7.0_25 onwards, calling this method + * requires a graphical environment and starts an AWT thread. */ - private boolean appContextProtection = true; + private boolean appContextProtection = !IS_JAVA_7_OR_LATER; public boolean isAppContextProtection() { return appContextProtection; } public void setAppContextProtection(boolean appContextProtection) { this.appContextProtection = appContextProtection; @@ -248,8 +266,15 @@ public class JreMemoryLeakPreventionList * due to eventual calls to getAppContext() are: * - Google Web Toolkit via its use of javax.imageio * - Tomcat via its use of java.beans.Introspector.flushCaches() - * in 1.6.0_15 onwards + * in 1.6.0_15 to 1.7.0_01. From 1.7.0_02 onwards use of + * AppContext by Introspector.flushCaches() was replaced with + * ThreadGroupContext * - others TBD + * + * From 1.7.0_25 onwards, a call to + * sun.awt.AppContext.getAppContext() results in a thread being + * started named AWT-AppKit that requires a graphic environment + * to be available. */ // Trigger a call to sun.awt.AppContext.getAppContext(). This 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=1496098&r1=1496097&r2=1496098&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Jun 24 15:33:33 2013 @@ -92,6 +92,12 @@ and when running as a service) since Tomcat will not be able to do any useful work. (markt) </fix> + <fix> + Update the <code>JreMemoryLeakPreventionListener</code> to take account + of changes in the behaviour of + <code>java.beans.Introspector.flushCaches()</code> and + <code>sun.awt.AppContext.getAppContext()</code> in Java 7. (markt) + </fix> </changelog> </subsection> <subsection name="Cluster"> 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=1496098&r1=1496097&r2=1496098&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml Mon Jun 24 15:33:33 2013 @@ -177,9 +177,11 @@ <p>Enables protection so that calls to <code>sun.awt.AppContext.getAppContext()</code> triggered by a web application do not result in a memory leak. Note that a call to this - method will be triggered as part of the web application stop process so - it is strongly recommended that this protection is enabled. The default - is <code>true</code>.</p> + method will be triggered as part of the web application stop process + when running on Java 6 and earlier. It is therefore strongly recommended + that this protection is enabled when running on Java 6 and earlier. The + default is <code>true</code> for Java 6 and earlier versions. The + default is <code>false</code> for Java 7 and later versions.</p> </attribute> <attribute name="AWTThreadProtection" required="false"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org