Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8737EC678 for ; Mon, 24 Jun 2013 15:34:00 +0000 (UTC) Received: (qmail 28217 invoked by uid 500); 24 Jun 2013 15:33:59 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 28052 invoked by uid 500); 24 Jun 2013 15:33:56 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 28042 invoked by uid 99); 24 Jun 2013 15:33:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2013 15:33:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Jun 2013 15:33:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3C7422388A2C for ; Mon, 24 Jun 2013 15:33:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1496098 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java webapps/docs/changelog.xml webapps/docs/config/listeners.xml Date: Mon, 24 Jun 2013 15:33:33 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130624153334.3C7422388A2C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 * sun.awt.AppContext.getAppContext() is triggered by a web - * application. Defaults to true. + * application. Defaults to true for Java 6 and earlier (since + * it is used by {@link java.beans.Introspector#flushCaches()}) but defaults + * to false 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) + + Update the JreMemoryLeakPreventionListener to take account + of changes in the behaviour of + java.beans.Introspector.flushCaches() and + sun.awt.AppContext.getAppContext() in Java 7. (markt) + 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 @@

Enables protection so that calls to sun.awt.AppContext.getAppContext() 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 true.

+ 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 true for Java 6 and earlier versions. The + default is false for Java 7 and later versions.

--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org