Author: kkolinko Date: Wed Oct 6 01:03:29 2010 New Revision: 1004868 URL: http://svn.apache.org/viewvc?rev=1004868&view=rev Log: Amending the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=49669 Do not depend on the deprecated class. Use reflection instead.
Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties 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=1004868&r1=1004867&r2=1004868&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Wed Oct 6 01:03:29 2010 @@ -25,7 +25,6 @@ import java.net.URL; import java.net.URLConnection; import javax.imageio.ImageIO; -import javax.security.auth.Policy; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -233,10 +232,24 @@ public class JreMemoryLeakPreventionList */ if (securityPolicyProtection) { try { - Policy.getPolicy(); + // Policy.getPolicy(); + Class<?> policyClass = Class + .forName("javax.security.auth.Policy"); + Method method = policyClass.getMethod("getPolicy"); + method.invoke(null); + } catch(ClassNotFoundException e) { + // Ignore. The class is deprecated. } catch(SecurityException e) { // Ignore. Don't need call to getPolicy() to be successful, // just need to trigger static initializer. + } catch (NoSuchMethodException e) { + log.warn(sm.getString("jreLeakListener.authPolicyFail"), e); + } catch (IllegalArgumentException e) { + log.warn(sm.getString("jreLeakListener.authPolicyFail"), e); + } catch (IllegalAccessException e) { + log.warn(sm.getString("jreLeakListener.authPolicyFail"), e); + } catch (InvocationTargetException e) { + log.warn(sm.getString("jreLeakListener.authPolicyFail"), e); } } Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1004868&r1=1004867&r2=1004868&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Wed Oct 6 01:03:29 2010 @@ -80,6 +80,7 @@ jreLeakListener.keepAliveFail=Failed to jreLeakListener.gcDaemonFail=Failed to trigger creation of the GC Daemon thread during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs. jreLeakListener.jarUrlConnCacheFail=Failed to disable Jar URL connection caching by default jreLeakListener.xmlParseFail=Error whilst attempting to prevent memory leaks during XML parsing +jreLeakListener.authPolicyFail=Error whilst attempting to prevent memory leak in javax.security.auth.Policy class naming.wsdlFailed=Failed to find wsdl file: {0} naming.bindFailed=Failed to bind object: {0} naming.jmxRegistrationFailed=Failed to register in JMX: {0} Modified: tomcat/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1004868&r1=1004867&r2=1004868&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/trunk/webapps/docs/config/listeners.xml Wed Oct 6 01:03:29 2010 @@ -271,8 +271,8 @@ service:jmx:rmi://<hostname>:10002 </attribute> <attribute name="securityPolicyProtection" required="false"> - <p>Enables protection so that usage of - <code>javax.security.auth.Policy</code> by a web application does not + <p>Enables protection so that usage of the deprecated + <code>javax.security.auth.Policy</code> class by a web application does not result in a memory leak. The first access of this class will trigger the static initializer that will retain a static reference to the context class loader. The protection calls the <code>getPolicy()</code> method --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org