This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 4264a7cc21 Improve clean-up of failed/removed Valves in Pipeline
4264a7cc21 is described below
commit 4264a7cc21e6f17b2512f53ae85e310bee904d7e
Author: Mark Thomas <[email protected]>
AuthorDate: Fri May 22 13:05:34 2026 +0100
Improve clean-up of failed/removed Valves in Pipeline
---
.../org/apache/catalina/core/StandardPipeline.java | 26 ++++++++++++++--------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/java/org/apache/catalina/core/StandardPipeline.java
b/java/org/apache/catalina/core/StandardPipeline.java
index 21c24efdb6..23385816a0 100644
--- a/java/org/apache/catalina/core/StandardPipeline.java
+++ b/java/org/apache/catalina/core/StandardPipeline.java
@@ -225,6 +225,7 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error(sm.getString("standardPipeline.basic.start"), e);
+ cleanupValve(valve);
return;
}
}
@@ -277,6 +278,8 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error(sm.getString("standardPipeline.valve.start"), e);
+ cleanupValve(valve);
+ return;
}
}
}
@@ -363,18 +366,25 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
first = null;
}
+ cleanupValve(valve);
+
+ container.fireContainerEvent(Container.REMOVE_VALVE_EVENT, valve);
+ }
+
+
+ /*
+ * Performs any necessary clean-up after a Valve failed to be set/added or
is removed
+ */
+ private void cleanupValve(Valve valve) {
if (valve instanceof Contained) {
((Contained) valve).setContainer(null);
}
if (valve instanceof Lifecycle) {
- // Stop this valve if necessary
- if (getState().isAvailable()) {
- try {
- ((Lifecycle) valve).stop();
- } catch (LifecycleException e) {
- log.error(sm.getString("standardPipeline.valve.stop"), e);
- }
+ try {
+ ((Lifecycle) valve).stop();
+ } catch (LifecycleException e) {
+ log.error(sm.getString("standardPipeline.valve.stop"), e);
}
try {
((Lifecycle) valve).destroy();
@@ -382,8 +392,6 @@ public class StandardPipeline extends LifecycleBase
implements Pipeline {
log.error(sm.getString("standardPipeline.valve.destroy"), e);
}
}
-
- container.fireContainerEvent(Container.REMOVE_VALVE_EVENT, valve);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]