Author: markt Date: Sat Oct 5 22:55:25 2013 New Revision: 1529547 URL: http://svn.apache.org/r1529547 Log: Partial fix for re-opened https://issues.apache.org/bugzilla/show_bug.cgi?id=49134 Ensure nested realms are correctly destroyed, ensuring that the associated MBeans are deregistered.
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/CombinedRealm.java tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1529546 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/CombinedRealm.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/CombinedRealm.java?rev=1529547&r1=1529546&r2=1529547&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/CombinedRealm.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/realm/CombinedRealm.java Sat Oct 5 22:55:25 2013 @@ -232,6 +232,20 @@ public class CombinedRealm extends Realm /** + * Ensure child Realms are destroyed when this Realm is destroyed. + */ + @Override + protected void destroyInternal() throws LifecycleException { + for (Realm realm : realms) { + if (realm instanceof Lifecycle) { + ((Lifecycle) realm).destroy(); + } + } + super.destroyInternal(); + } + + + /** * Return the Principal associated with the specified chain of X509 * client certificates. If there is none, return <code>null</code>. * Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java?rev=1529547&r1=1529546&r2=1529547&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/mbeans/TestRegistration.java Sat Oct 5 22:55:25 2013 @@ -33,7 +33,11 @@ import static org.junit.Assert.fail; import org.junit.Test; +import org.apache.catalina.Context; +import org.apache.catalina.Realm; import org.apache.catalina.core.StandardHost; +import org.apache.catalina.realm.CombinedRealm; +import org.apache.catalina.realm.NullRealm; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; import org.apache.tomcat.util.modeler.Registry; @@ -106,6 +110,10 @@ public class TestRegistration extends To ",host=" + host + ",name=StandardContextValve", "Tomcat:type=WebappClassLoader,context=" + context + ",host=" + host, + "Tomcat:type=Realm,realmPath=/realm0,context=" + context + + ",host=" + host, + "Tomcat:type=Realm,realmPath=/realm0/realm0,context=" + context + + ",host=" + host, }; } @@ -146,7 +154,13 @@ public class TestRegistration extends To if (!contextDir.mkdirs() && !contextDir.isDirectory()) { fail("Failed to create: [" + contextDir.toString() + "]"); } - tomcat.addContext(contextName, contextDir.getAbsolutePath()); + Context ctx = tomcat.addContext(contextName, contextDir.getAbsolutePath()); + + CombinedRealm combinedRealm = new CombinedRealm(); + Realm nullRealm = new NullRealm(); + combinedRealm.addRealm(nullRealm); + ctx.setRealm(combinedRealm); + tomcat.start(); // Verify there are no Catalina MBeans 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=1529547&r1=1529546&r2=1529547&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sat Oct 5 22:55:25 2013 @@ -64,6 +64,11 @@ IOException may be in response to the client continuing to send a message after the server sent a close control message. (markt) </fix> + <fix> + <bug>49134</bug>: Ensure nested realms are correctly destroyed, when a + CombinedRealm is destroyed. This ensures that the associated MBeans are + deregistered. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org