You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/24 16:06:24 UTC
svn commit: r1496061 - in /tomcat/trunk:
java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
webapps/docs/config/listeners.xml
Author: markt
Date: Mon Jun 24 14:06:24 2013
New Revision: 1496061
URL: http://svn.apache.org/r1496061
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/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
tomcat/trunk/webapps/docs/config/listeners.xml
Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1496061&r1=1496060&r2=1496061&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Mon Jun 24 14:06:24 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;
@@ -250,8 +268,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/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1496061&r1=1496060&r2=1496061&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Mon Jun 24 14:06:24 2013
@@ -178,9 +178,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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1496061 - in /tomcat/trunk: java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
webapps/docs/config/listeners.xml
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,
On 6/24/13 10:06 AM, markt@apache.org wrote:
> Author: markt
> Date: Mon Jun 24 14:06:24 2013
> New Revision: 1496061
>
> URL: http://svn.apache.org/r1496061
> 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/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
> tomcat/trunk/webapps/docs/config/listeners.xml
>
> Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1496061&r1=1496060&r2=1496061&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Mon Jun 24 14:06:24 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;
> + }
Isn't there a better way to detect Java versions? Maybe detect the
version string and do a comparison?
-chris