This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 3dca097687 Fix complete status output with a failed context
3dca097687 is described below
commit 3dca097687e935e57d28e9b915f8d8a4b3d3c0a5
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Nov 13 10:29:49 2025 +0000
Fix complete status output with a failed context
---
.../apache/catalina/manager/StatusTransformer.java | 40 ++++++++++++++++------
webapps/docs/changelog.xml | 5 +++
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/java/org/apache/catalina/manager/StatusTransformer.java
b/java/org/apache/catalina/manager/StatusTransformer.java
index dd543520c1..bf0ab3d75c 100644
--- a/java/org/apache/catalina/manager/StatusTransformer.java
+++ b/java/org/apache/catalina/manager/StatusTransformer.java
@@ -34,6 +34,7 @@ import javax.management.ObjectName;
import jakarta.servlet.http.HttpServletResponse;
+import org.apache.catalina.LifecycleState;
import org.apache.tomcat.util.json.JSONFilter;
import org.apache.tomcat.util.security.Escape;
@@ -795,6 +796,8 @@ public class StatusTransformer {
contextName = "";
}
+ Object stateName = mBeanServer.getAttribute(objectName, "stateName");
+
if (mode == 0) {
writer.print("<h1>");
@@ -803,12 +806,19 @@ public class StatusTransformer {
writer.print("</a>");
writer.print("<p>");
- Object startTime = mBeanServer.getAttribute(objectName,
"startTime");
- writer.print(" Start time: " + new Date(((Long)
startTime).longValue()));
- writer.print(" Startup time: ");
- writer.print(formatTime(mBeanServer.getAttribute(objectName,
"startupTime"), false));
- writer.print(" TLD scan time: ");
- writer.print(formatTime(mBeanServer.getAttribute(objectName,
"tldScanTime"), false));
+ writer.print("State: " + stateName);
+ if (!LifecycleState.FAILED.name().equals(stateName)) {
+ /*
+ * If in the FAILED state, the context will be an instance of
FailedContext so the attributes normally
+ * requested for a running context won't be available.
+ */
+ Object startTime = mBeanServer.getAttribute(objectName,
"startTime");
+ writer.print(" Start time: " + new Date(((Long)
startTime).longValue()));
+ writer.print(" Startup time: ");
+ writer.print(formatTime(mBeanServer.getAttribute(objectName,
"startupTime"), false));
+ writer.print(" TLD scan time: ");
+ writer.print(formatTime(mBeanServer.getAttribute(objectName,
"tldScanTime"), false));
+ }
if (managerON != null) {
writeManager(writer, managerON, mBeanServer, mode);
}
@@ -829,11 +839,19 @@ public class StatusTransformer {
} else if (mode == 2) {
indent(writer, 2).append('{').println();
appendJSonValue(indent(writer, 3), "name",
JSONFilter.escape(JSONFilter.escape(name))).append(',');
- appendJSonValue(writer, "startTime",
- new Date(((Long) mBeanServer.getAttribute(objectName,
"startTime")).longValue()).toString())
- .append(',');
- appendJSonValue(writer, "startupTime",
mBeanServer.getAttribute(objectName, "startupTime")).append(',');
- appendJSonValue(writer, "tldScanTime",
mBeanServer.getAttribute(objectName, "tldScanTime"));
+ appendJSonValue(writer, "stateName", stateName);
+ if (!LifecycleState.FAILED.name().equals(stateName)) {
+ /*
+ * If in the FAILED state, the context will be an instance of
FailedContext so the attributes normally
+ * requested for a running context won't be available.
+ */
+ writer.append(',');
+ appendJSonValue(writer, "startTime",
+ new Date(((Long) mBeanServer.getAttribute(objectName,
"startTime")).longValue()).toString())
+ .append(',');
+ appendJSonValue(writer, "startupTime",
mBeanServer.getAttribute(objectName, "startupTime")).append(',');
+ appendJSonValue(writer, "tldScanTime",
mBeanServer.getAttribute(objectName, "tldScanTime"));
+ }
if (managerON != null) {
writeManager(writer, managerON, mBeanServer, mode);
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 30cbe95124..0923e3c935 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -304,6 +304,11 @@
<subsection name="Web applications">
<changelog>
<!-- Entries for backport and removal before 12.0.0-M1 below this line
-->
+ <fix>
+ Manager: Fix abrupt truncation of the HTML and JSON complete server
+ status output if one or more of the web applications failed to start.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Other">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]