tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1029755 - in /tomcat/trunk: java/org/apache/catalina/mbeans/MBeanUtils.java java/org/apache/catalina/valves/ValveBase.java webapps/docs/changelog.xml
Date Mon, 01 Nov 2010 17:22:33 GMT
Author: markt
Date: Mon Nov  1 17:22:33 2010
New Revision: 1029755

URL: http://svn.apache.org/viewvc?rev=1029755&view=rev
Log:
Make Tomcat more tolerant of nulls when generating JMX names for Valves.

Modified:
    tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
    tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java?rev=1029755&r1=1029754&r2=1029755&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanUtils.java Mon Nov  1 17:22:33 2010
@@ -1690,7 +1690,7 @@ public class MBeanUtils {
         
         Container c = container;
         StringBuilder keyProperties = new StringBuilder();
-        int unknown = 0;
+        int containerCount = 0;
         
         // Work up container hierarchy, add a component to the name for
         // each container
@@ -1708,10 +1708,16 @@ public class MBeanUtils {
             } else if (c instanceof Host) {
                 keyProperties.append(",host=");
                 keyProperties.append(c.getName());
+            } else if (c == null) {
+                // May happen in unit testing and/or some embedding scenarios
+                keyProperties.append(",container");
+                keyProperties.append(containerCount++);
+                keyProperties.append("=null");
+                break;
             } else {
                 // Should never happen...
-                keyProperties.append(",unknown");
-                keyProperties.append(unknown++);
+                keyProperties.append(",container");
+                keyProperties.append(containerCount++);
                 keyProperties.append('=');
                 keyProperties.append(c.getName());
             }

Modified: tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java?rev=1029755&r1=1029754&r2=1029755&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java (original)
+++ tomcat/trunk/java/org/apache/catalina/valves/ValveBase.java Mon Nov  1 17:22:33 2010
@@ -27,6 +27,7 @@ import org.apache.catalina.Contained;
 import org.apache.catalina.Container;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleState;
+import org.apache.catalina.Pipeline;
 import org.apache.catalina.Valve;
 import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.Request;
@@ -289,19 +290,24 @@ public abstract class ValveBase extends 
         name.append(MBeanUtils.getContainerKeyProperties(container));
         
         int seq = 0;
-        for (Valve valve : container.getPipeline().getValves()) {
-            // Skip null valves
-            if (valve == null) {
-                continue;
-            }
-            // Only compare valves in pipeline until we find this valve
-            if (valve == this) {
-                break;
-            }
-            if (valve.getClass() == this.getClass()) {
-                // Duplicate valve earlier in pipeline
-                // increment sequence number
-                seq ++;
+        
+        // Pipeline may not be present in unit testing
+        Pipeline p = container.getPipeline();
+        if (p != null) {
+            for (Valve valve : p.getValves()) {
+                // Skip null valves
+                if (valve == null) {
+                    continue;
+                }
+                // Only compare valves in pipeline until we find this valve
+                if (valve == this) {
+                    break;
+                }
+                if (valve.getClass() == this.getClass()) {
+                    // Duplicate valve earlier in pipeline
+                    // increment sequence number
+                    seq ++;
+                }
             }
         }
         

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1029755&r1=1029754&r2=1029755&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Mon Nov  1 17:22:33 2010
@@ -87,6 +87,10 @@
         <bug>49180</bug>: Add option to disable log rotation in 
         juli FileHandler. credit: Pid (pidster at apache )
       </fix>
+      <fix>
+        Make Tomcat more tolerant of <code>null</code> when generating JMX names
+        for Valves. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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


Mime
View raw message