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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to