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
} 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());
}
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;
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 ++;
+ }
}
}
<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">