You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/10/06 00:53:06 UTC
svn commit: r1529546 - in /tomcat/trunk:
java/org/apache/catalina/realm/CombinedRealm.java
test/org/apache/catalina/mbeans/TestRegistration.java
Author: markt
Date: Sat Oct 5 22:53:05 2013
New Revision: 1529546
URL: http://svn.apache.org/r1529546
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/trunk/java/org/apache/catalina/realm/CombinedRealm.java
tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
Modified: tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java?rev=1529546&r1=1529545&r2=1529546&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java (original)
+++ tomcat/trunk/java/org/apache/catalina/realm/CombinedRealm.java Sat Oct 5 22:53:05 2013
@@ -245,6 +245,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/trunk/test/org/apache/catalina/mbeans/TestRegistration.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java?rev=1529546&r1=1529545&r2=1529546&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java (original)
+++ tomcat/trunk/test/org/apache/catalina/mbeans/TestRegistration.java Sat Oct 5 22:53:05 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;
@@ -108,6 +112,10 @@ public class TestRegistration extends To
",host=" + host,
"Tomcat:type=WebResourceRoot,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
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org