You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sl...@apache.org on 2010/12/03 23:19:11 UTC

svn commit: r1042029 - in /tomcat: tc6.0.x/trunk/STATUS.txt trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java trunk/webapps/docs/changelog.xml trunk/webapps/docs/config/listeners.xml

Author: slaurent
Date: Fri Dec  3 22:19:11 2010
New Revision: 1042029

URL: http://svn.apache.org/viewvc?rev=1042029&view=rev
Log:
bug 50282 : Load javax.security.auth.login.Configuration with JreMemoryLeakPreventionListener to avoid memory leak when stopping a webapp that would use JAAS.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
    tomcat/trunk/webapps/docs/changelog.xml
    tomcat/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=1042029&r1=1042028&r2=1042029&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Dec  3 22:19:11 2010
@@ -213,4 +213,10 @@ PATCHES PROPOSED TO BACKPORT:
   The patch provided by Marc Guillemot works for tc 6 & 7
   +1: slaurent
   -1:
+
+* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50282
+  Improve JreMemoryLeakPreventionListener to load 
+  javax.security.auth.login.Configuration to avoid redeployment leak.
+  +1: slaurent
+  -1:
   
\ No newline at end of file

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=1042029&r1=1042028&r2=1042029&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Fri Dec  3 22:19:11 2010
@@ -107,7 +107,21 @@ public class JreMemoryLeakPreventionList
          this.securityPolicyProtection = securityPolicyProtection;
      }
      
-    /**
+     /**
+      * Protect against the memory leak caused when the first call to
+      * <code>javax.security.auth.login.Configuration</code> is triggered by a web
+      * application. This first call populate a static variable with a reference
+      * to the context class loader. Defaults to <code>true</code>.
+      */
+     private boolean securityLoginConfigurationProtection = true;
+     public boolean isSecurityLoginConfigurationProtection() {
+         return securityLoginConfigurationProtection;
+     }
+     public void setSecurityLoginConfigurationProtection(boolean securityLoginConfigurationProtection) {
+         this.securityLoginConfigurationProtection = securityLoginConfigurationProtection;
+     }
+
+     /**
      * Protect against the memory leak, when the initialization of the
      * Java Cryptography Architecture is triggered by initializing
      * a MessageDigest during web application deployment.
@@ -274,6 +288,19 @@ public class JreMemoryLeakPreventionList
                     }
                 }
     
+                
+                /*
+                 * Initializing javax.security.auth.login.Configuration retains a static reference to the context 
+                 * class loader.
+                 */
+                if (securityLoginConfigurationProtection) {
+                    try {
+                        Class.forName("javax.security.auth.login.Configuration", true, ClassLoader.getSystemClassLoader());
+                    } catch(ClassNotFoundException e) {
+                        // Ignore
+                    }
+                }
+
                 /*
                  * Creating a MessageDigest during web application startup
                  * initializes the Java Cryptography Architecture. Under certain

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1042029&r1=1042028&r2=1042029&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Dec  3 22:19:11 2010
@@ -43,6 +43,12 @@
   <subsection name="Catalina">
     <changelog>
       <add>
+        <bug>50282</bug>: Load <code>javax.security.auth.login.Configuration</code>
+        with <code>JreMemoryLeakPreventionListener</code> to avoid memory leak
+        when stopping a webapp that would use JAAS.
+        (slaurent)
+      </add>
+      <add>
         <bug>48973</bug>: Avoid creating a SESSIONS.ser file when stopping an 
         application if there's no session. Patch provided by Marc Guillemot.
         (slaurent)

Modified: tomcat/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1042029&r1=1042028&r2=1042029&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Fri Dec  3 22:19:11 2010
@@ -270,6 +270,16 @@ service:jmx:rmi://&lt;hostname&gt;:10002
         trigger a memory leak on reload. Defaults to <code>true</code>.</p>
       </attribute>
 
+      <attribute name="securityLoginConfigurationProtection" required="false">
+        <p>Enables protection so that usage of the
+        <code>javax.security.auth.login.Configuration</code> class by a web 
+        application does not in a memory leak. The first access of this class will
+        trigger the initializer that will retain a static reference to the context
+        class loader. The protection loads the class with the system classloader 
+        to ensure that the static initializer is not triggered by web application.
+        Defaults to <code>true</code>.</p>
+      </attribute>
+
       <attribute name="securityPolicyProtection" required="false">
         <p>Enables protection so that usage of the deprecated
         <code>javax.security.auth.Policy</code> class by a web application does not



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


Re: svn commit: r1042029 - in /tomcat: tc6.0.x/trunk/STATUS.txt trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java trunk/webapps/docs/changelog.xml trunk/webapps/docs/config/listeners.xml

Posted by Mark Thomas <ma...@apache.org>.
On 03/12/2010 22:19, slaurent@apache.org wrote:
> Author: slaurent
> Date: Fri Dec  3 22:19:11 2010
> New Revision: 1042029
> 
> URL: http://svn.apache.org/viewvc?rev=1042029&view=rev

Comments in-line.

> 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=1042029&r1=1042028&r2=1042029&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original)
> +++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Fri Dec  3 22:19:11 2010
> @@ -107,7 +107,21 @@ public class JreMemoryLeakPreventionList
>           this.securityPolicyProtection = securityPolicyProtection;
>       }
>       
> -    /**
> +     /**
> +      * Protect against the memory leak caused when the first call to
> +      * <code>javax.security.auth.login.Configuration</code> is triggered by a web
> +      * application. This first call populate a static variable with a reference
> +      * to the context class loader. Defaults to <code>true</code>.
> +      */
> +     private boolean securityLoginConfigurationProtection = true;
> +     public boolean isSecurityLoginConfigurationProtection() {
> +         return securityLoginConfigurationProtection;
> +     }
> +     public void setSecurityLoginConfigurationProtection(boolean securityLoginConfigurationProtection) {
> +         this.securityLoginConfigurationProtection = securityLoginConfigurationProtection;
> +     }
Tomcat code style is to limit line length to a maximum of 80 characters.
No all files stick to this but new code generally should.

>    <subsection name="Catalina">
>      <changelog>
>        <add>
> +        <bug>50282</bug>: Load <code>javax.security.auth.login.Configuration</code>
> +        with <code>JreMemoryLeakPreventionListener</code> to avoid memory leak
> +        when stopping a webapp that would use JAAS.
> +        (slaurent)
> +      </add>
> +      <add>
webapp is usually written in full as web application in the change log.

> +      <attribute name="securityLoginConfigurationProtection" required="false">
> +        <p>Enables protection so that usage of the
> +        <code>javax.security.auth.login.Configuration</code> class by a web 
> +        application does not in a memory leak. The first access of this class will
> +        trigger the initializer that will retain a static reference to the context
> +        class loader. The protection loads the class with the system classloader 
> +        to ensure that the static initializer is not triggered by web application.
> +        Defaults to <code>true</code>.</p>
> +      </attribute>
classloader should be written as class loader.

Mark

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


Re: svn commit: r1042029 - in /tomcat: tc6.0.x/trunk/STATUS.txt trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java trunk/webapps/docs/changelog.xml trunk/webapps/docs/config/listeners.xml

Posted by Sylvain Laurent <sy...@m4x.org>.
ok, thanks for having added them for me.

Sylvain


On 4 déc. 2010, at 06:21, Konstantin Kolinko wrote:

> 2010/12/4  <sl...@apache.org>:
>> Author: slaurent
>> Date: Fri Dec  3 22:19:11 2010
>> New Revision: 1042029
>> 
>> URL: http://svn.apache.org/viewvc?rev=1042029&view=rev
>> Log:
>> bug 50282 : Load javax.security.auth.login.Configuration with JreMemoryLeakPreventionListener to avoid memory leak when stopping a webapp that would use JAAS.
>> 
>> Modified:
>>    tomcat/tc6.0.x/trunk/STATUS.txt
>>    tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
>>    tomcat/trunk/webapps/docs/changelog.xml
>>    tomcat/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=1042029&r1=1042028&r2=1042029&view=diff
>> +
>> +* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50282
>> +  Improve JreMemoryLeakPreventionListener to load
>> +  javax.security.auth.login.Configuration to avoid redeployment leak.
>> +  +1: slaurent
>> +  -1:
> 
> You must include patch URL in your proposal. (What are we voting for?)
> Thus, you usually cannot mix update to STATUS and update to trunk in
> the same commit.
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


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


Re: svn commit: r1042029 - in /tomcat: tc6.0.x/trunk/STATUS.txt trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java trunk/webapps/docs/changelog.xml trunk/webapps/docs/config/listeners.xml

Posted by Konstantin Kolinko <kn...@gmail.com>.
2010/12/4  <sl...@apache.org>:
> Author: slaurent
> Date: Fri Dec  3 22:19:11 2010
> New Revision: 1042029
>
> URL: http://svn.apache.org/viewvc?rev=1042029&view=rev
> Log:
> bug 50282 : Load javax.security.auth.login.Configuration with JreMemoryLeakPreventionListener to avoid memory leak when stopping a webapp that would use JAAS.
>
> Modified:
>    tomcat/tc6.0.x/trunk/STATUS.txt
>    tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
>    tomcat/trunk/webapps/docs/changelog.xml
>    tomcat/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=1042029&r1=1042028&r2=1042029&view=diff
> +
> +* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50282
> +  Improve JreMemoryLeakPreventionListener to load
> +  javax.security.auth.login.Configuration to avoid redeployment leak.
> +  +1: slaurent
> +  -1:

You must include patch URL in your proposal. (What are we voting for?)
Thus, you usually cannot mix update to STATUS and update to trunk in
the same commit.

Best regards,
Konstantin Kolinko

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