Commit fe43f6df authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 8.5.34

parent 9897e46c
......@@ -45,15 +45,15 @@ source distribution, do the following:
Note regarding later versions of Java:
As documented elsewhere, one of components in Apache Tomcat includes
a private copy of the Apache Commons DBCP library.
a private copy of the Apache Commons DBCP 2 library.
The JDBC interfaces implemented by DBCP frequently change in non-backwards
compatible ways between versions of the Java SE specification. Therefore,
it is likely that DBCP will only compile with the specific version of Java
it is likely that DBCP 2 will only compile with the specific version of Java
listed above and that compilation will fail if a later version of Java is
used.
See Apache Commons DBCP project web site for more details on
See Apache Commons DBCP 2 project web site for more details on
available versions of the library and its requirements,
https://commons.apache.org/dbcp/
......
......@@ -85,7 +85,7 @@ for use by web applications (by placing them in "lib"):
* servlet-api.jar (Servlet 3.1 API)
* tomcat-api.jar (Interfaces shared by Catalina and Jasper)
* tomcat-coyote.jar (Tomcat connectors and utility classes)
* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP)
* tomcat-dbcp.jar (package renamed database connection pool based on Commons DBCP 2)
* tomcat-jdbc.jar (Tomcat's database connection pooling solution)
* tomcat-jni.jar (Interface to the native component of the APR/native connector)
* tomcat-util.jar (Various utilities)
......
......@@ -25,7 +25,7 @@
# ----- Version Control Flags -----
version.major=8
version.minor=5
version.build=33
version.build=34
version.patch=0
version.suffix=
......@@ -89,7 +89,7 @@ compile.debug=true
# Do not pass -deprecation (-Xlint:deprecation) flag to javac
compile.deprecation=false
base-apache.loc.1=https://www.apache.org/dyn/closer.lua?action=download&filename=
base-apache.loc.1=http://www.apache.org/dyn/closer.lua?action=download&filename=
base-apache.loc.2=https://archive.apache.org/dist
base-commons.loc.1=${base-apache.loc.1}/commons
base-commons.loc.2=${base-apache.loc.2}/commons
......
......@@ -830,7 +830,7 @@
filesDir="${tomcat.classes}"
filesId="files.jasper-el" />
<!-- Re-packaged Apache Commons DBCP-->
<!-- Re-packaged Apache Commons DBCP 2-->
<jarIt jarfile="${tomcat-dbcp.jar}"
filesDir="${tomcat.classes}"
filesId="files.tomcat-dbcp" />
......@@ -1308,7 +1308,6 @@
<fileset dir="${tomcat.embed}">
<include name="**" />
<exclude name="*.asc" />
<exclude name="*.sha1" />
<exclude name="*.sha512" />
<exclude name="*.zip" />
<exclude name="*.tar.gz" />
......@@ -1325,7 +1324,6 @@
<tarfileset dir="${tomcat.embed}" prefix="${final.name}-embed">
<include name="**" />
<exclude name="*.asc" />
<exclude name="*.sha1" />
<exclude name="*.sha512" />
<exclude name="*.zip" />
<exclude name="*.tar.gz" />
......@@ -2155,7 +2153,6 @@ skip.installer property in build.properties" />
</signcode>
<!-- .exe has changed so need to redo checksums and OpenPGP signature -->
<delete file="${tomcat.release}/v${version}/bin/${final.name}.exe.asc" />
<delete file="${tomcat.release}/v${version}/bin/${final.name}.exe.sha1" />
<delete file="${tomcat.release}/v${version}/bin/${final.name}.exe.sha512" />
<hashAndSign file="${tomcat.release}/v${version}/bin/${final.name}.exe" />
</target>
......@@ -2195,7 +2192,6 @@ skip.installer property in build.properties" />
<include name="*.zip"/>
<include name="*.tar.gz"/>
<include name="*.asc"/>
<include name="*.sha1"/>
<include name="*.sha512"/>
</fileset>
</copy>
......@@ -2580,7 +2576,7 @@ skip.installer property in build.properties" />
filesDir="java"
filesId="files.jasper-el" />
<!-- Repackaged DBCP -->
<!-- Repackaged DBCP 2 -->
<jarIt jarfile="${tomcat-dbcp-src.jar}"
filesDir="java"
filesId="files.tomcat-dbcp" />
......@@ -3148,14 +3144,11 @@ Read the Building page on the Apache Tomcat documentation site for details on ho
<attribute name="file" />
<sequential>
<local name="filename" />
<local name="sha1value" />
<local name="sha512value" />
<basename file="@{file}" property="filename" />
<checksum algorithm="SHA-1" file="@{file}" property="sha1value" />
<checksum algorithm="SHA-512" file="@{file}" property="sha512value" />
<echo file="@{file}.sha1" message="${sha1value}${md5sum.binary-prefix}${filename}" />
<echo file="@{file}.sha512" message="${sha512value}${md5sum.binary-prefix}${filename}" />
<antcall target="sign" >
......
......@@ -118,9 +118,13 @@ public final class Globals {
* We do this because of the pathInfo mangling happening when using
* the CGIServlet in conjunction with the SSI servlet. (value stored
* as an object of type String)
*
* @deprecated Unused. This is no longer used as the CGIO servlet now has
* generic handling for when it is used as an include.
* This will be removed in Tomcat 10
*/
public static final String SSI_FLAG_ATTR =
"org.apache.catalina.ssi.SSIServlet";
@Deprecated
public static final String SSI_FLAG_ATTR = "org.apache.catalina.ssi.SSIServlet";
/**
......
......@@ -1380,6 +1380,25 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
return (context.getServletContext().getRequestDispatcher(path));
}
/*
* Relative to what, exactly?
*
* From the Servlet 4.0 Javadoc:
* - The pathname specified may be relative, although it cannot extend
* outside the current servlet context.
* - If it is relative, it must be relative against the current servlet
*
* From Section 9.1 of the spec:
* - The servlet container uses information in the request object to
* transform the given relative path against the current servlet to a
* complete path.
*
* It is undefined whether the requestURI is used or whether servletPath
* and pathInfo are used. Given that the RequestURI includes the
* contextPath (and extracting that is messy) , using the servletPath and
* pathInfo looks to be the more reasonable choice.
*/
// Convert a request-relative path to a context-relative one
String servletPath = (String) getAttribute(
RequestDispatcher.INCLUDE_SERVLET_PATH);
......@@ -3208,11 +3227,6 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
return;
}
if( !getConnector().isParseBodyMethod(getMethod()) ) {
success = true;
return;
}
String contentType = getContentType();
if (contentType == null) {
contentType = "";
......@@ -3230,6 +3244,11 @@ public class Request implements org.apache.catalina.servlet4preview.http.HttpSer
return;
}
if( !getConnector().isParseBodyMethod(getMethod()) ) {
success = true;
return;
}
if (!("application/x-www-form-urlencoded".equals(contentType))) {
success = true;
return;
......
......@@ -405,9 +405,8 @@ public class ApplicationContext implements org.apache.catalina.servlet4preview.S
sm.getString("applicationContext.requestDispatcher.iae", path));
}
// Need to separate the query string and the uri. This is required for
// the ApplicationDispatcher constructor. Mapping also requires the uri
// without the query string.
// Same processing order as InputBuffer / CoyoteAdapter
// First remove query string
String uri;
String queryString;
int pos = path.indexOf('?');
......@@ -419,18 +418,24 @@ public class ApplicationContext implements org.apache.catalina.servlet4preview.S
queryString = null;
}
String normalizedPath = RequestUtil.normalize(uri);
if (normalizedPath == null) {
// Remove path parameters
String uriNoParams = stripPathParams(uri);
// Then normalize
String normalizedUri = RequestUtil.normalize(uriNoParams);
if (normalizedUri == null) {
return (null);
}
// Mapping is against the normalized uri
if (getContext().getDispatchersUseEncodedPaths()) {
// Decode
String decodedPath = UDecoder.URLDecode(normalizedPath);
String decodedUri = UDecoder.URLDecode(normalizedUri);
// Security check to catch attempts to encode /../ sequences
normalizedPath = RequestUtil.normalize(decodedPath);
if (!decodedPath.equals(normalizedPath)) {
normalizedUri = RequestUtil.normalize(decodedUri);
if (!decodedUri.equals(normalizedUri)) {
getContext().getLogger().warn(
sm.getString("applicationContext.illegalDispatchPath", path),
new IllegalArgumentException());
......@@ -447,7 +452,7 @@ public class ApplicationContext implements org.apache.catalina.servlet4preview.S
uri = URLEncoder.DEFAULT.encode(getContextPath() + uri, StandardCharsets.UTF_8);
}
pos = normalizedPath.length();
pos = normalizedUri.length();
// Use the thread local URI and mapping data
DispatchData dd = dispatchData.get();
......@@ -462,47 +467,64 @@ public class ApplicationContext implements org.apache.catalina.servlet4preview.S
// Use the thread local mapping data
MappingData mappingData = dd.mappingData;
// Map the URI
CharChunk uriCC = uriMB.getCharChunk();
try {
uriCC.append(context.getPath(), 0, context.getPath().length());
/*
* Ignore any trailing path params (separated by ';') for mapping
* purposes
*/
int semicolon = normalizedPath.indexOf(';');
if (pos >= 0 && semicolon > pos) {
semicolon = -1;
}
uriCC.append(normalizedPath, 0, semicolon > 0 ? semicolon : pos);
service.getMapper().map(context, uriMB, mappingData);
if (mappingData.wrapper == null) {
return (null);
}
/*
* Append any trailing path params (separated by ';') that were
* ignored for mapping purposes, so that they're reflected in the
* RequestDispatcher's requestURI
*/
if (semicolon > 0) {
uriCC.append(normalizedPath, semicolon, pos - semicolon);
// Map the URI
CharChunk uriCC = uriMB.getCharChunk();
try {
uriCC.append(context.getPath());
uriCC.append(normalizedUri);
service.getMapper().map(context, uriMB, mappingData);
if (mappingData.wrapper == null) {
return null;
}
} catch (Exception e) {
// Should never happen
log(sm.getString("applicationContext.mapping.error"), e);
return null;
}
} catch (Exception e) {
// Should never happen
log(sm.getString("applicationContext.mapping.error"), e);
return (null);
Wrapper wrapper = mappingData.wrapper;
String wrapperPath = mappingData.wrapperPath.toString();
String pathInfo = mappingData.pathInfo.toString();
ServletMapping mapping = new ApplicationMapping(mappingData).getServletMapping();
// Construct a RequestDispatcher to process this request
return new ApplicationDispatcher(wrapper, uri, wrapperPath, pathInfo,
queryString, mapping, null);
} finally {
// Recycle thread local data at the end of the request so references
// are not held to a completed request as there is potential for
// that to trigger a memory leak if a context is unloaded.
mappingData.recycle();
}
}
Wrapper wrapper = mappingData.wrapper;
String wrapperPath = mappingData.wrapperPath.toString();
String pathInfo = mappingData.pathInfo.toString();
ServletMapping mapping = (new ApplicationMapping(mappingData)).getServletMapping();
mappingData.recycle();
// Package private to facilitate testing
static String stripPathParams(String input) {
// Shortcut
if (input.indexOf(';') < 0) {
return input;
}
StringBuilder sb = new StringBuilder(input.length());
int pos = 0;
int limit = input.length();
while (pos < limit) {
int nextSemiColon = input.indexOf(';', pos);
if (nextSemiColon < 0) {
nextSemiColon = limit;
}
sb.append(input.substring(pos, nextSemiColon));
int followingSlash = input.indexOf('/', nextSemiColon);
if (followingSlash < 0) {
pos = limit;
} else {
pos = followingSlash;
}
}
// Construct a RequestDispatcher to process this request
return new ApplicationDispatcher(wrapper, uri, wrapperPath, pathInfo,
queryString, mapping, null);
return sb.toString();
}
......
......@@ -235,6 +235,21 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
// Initialise these classes when Tomcat starts
if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
/*
* First call to this loads all drivers visible to the current class
* loader and its parents.
*
* Note: This is called before the context class loader is changed
* because we want any drivers located in CATALINA_HOME/lib
* and/or CATALINA_HOME/lib to be visible to DriverManager.
* Users wishing to avoid having JDBC drivers loaded by this
* class loader should add the JDBC driver(s) to the class
* path so they are loaded by the system class loader.
*/
if (driverManagerProtection) {
DriverManager.getDrivers();
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try
......@@ -244,14 +259,6 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
Thread.currentThread().setContextClassLoader(
ClassLoader.getSystemClassLoader());
/*
* First call to this loads all drivers in the current class
* loader
*/
if (driverManagerProtection) {
DriverManager.getDrivers();
}
/*
* Several components end up calling:
* sun.awt.AppContext.getAppContext()
......
......@@ -134,3 +134,38 @@ managerServlet.unknownCommand=FAIL - Unknown command [{0}]
managerServlet.vminfo=OK - VM info
statusServlet.title=Server Status
statusServlet.complete=Complete Server Status
htmlManagerServlet.osPhysicalMemory=Physical memory:
htmlManagerServlet.osAvailableMemory=Available memory:
htmlManagerServlet.osTotalPageFile=Total page file:
htmlManagerServlet.osFreePageFile=Free page file:
htmlManagerServlet.osMemoryLoad=Memory load:
htmlManagerServlet.osKernelTime=Process kernel time:
htmlManagerServlet.osUserTime=Process user time:
htmlManagerServlet.jvmFreeMemory=Free Memory:
htmlManagerServlet.jvmMaxMemory=Max Memory:
htmlManagerServlet.jvmTotalMemory=Total Memory:
htmlManagerServlet.jvmTableTitleMemoryPool=Memory Pool
htmlManagerServlet.jvmTableTitleType=Type
htmlManagerServlet.jvmTableTitleInitial=Initial
htmlManagerServlet.jvmTableTitleTotal=Total
htmlManagerServlet.jvmTableTitleMaximum=Maximum
htmlManagerServlet.jvmTableTitleUsed=Used
htmlManagerServlet.connectorStateMaxThreads=Max threads:
htmlManagerServlet.connectorStateThreadCount=Current thread count:
htmlManagerServlet.connectorStateThreadBusy=Current thread busy:
htmlManagerServlet.connectorStateAliveSocketCount=Keep alive sockets count:
htmlManagerServlet.connectorStateMaxProcessingTime=Max processing time:
htmlManagerServlet.connectorStateProcessingTime=Processing time:
htmlManagerServlet.connectorStateRequestCount=Request count:
htmlManagerServlet.connectorStateErrorCount=Error count:
htmlManagerServlet.connectorStateBytesRecieved=Bytes received:
htmlManagerServlet.connectorStateBytesSent=Bytes sent:
htmlManagerServlet.connectorStateTableTitleStage=Stage
htmlManagerServlet.connectorStateTableTitleTime=Time
htmlManagerServlet.connectorStateTableTitleBSent=B Sent
htmlManagerServlet.connectorStateTableTitleBRecv=B Recv
htmlManagerServlet.connectorStateTableTitleClientForw=Client (Forwarded)
htmlManagerServlet.connectorStateTableTitleClientAct=Client (Actual)
htmlManagerServlet.connectorStateTableTitleVHost=VHost
htmlManagerServlet.connectorStateTableTitleRequest=Request
htmlManagerServlet.connectorStateHint=P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive
......@@ -136,3 +136,38 @@ managerServlet.unknownCommand=\u041e\u0428\u0418\u0411\u041a\u0410 - \u041d\u043
managerServlet.vminfo=OK - \u0056\u004d \u0438\u043d\u0444\u043e
statusServlet.title=\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
statusServlet.complete=\u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430
htmlManagerServlet.osPhysicalMemory=\u0424\u0438\u0437\u0438\u0447\u0435\u0441\u043A\u0430\u044F \u043F\u0430\u043C\u044F\u0442\u044C:
htmlManagerServlet.osAvailableMemory=\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u0430\u044F \u043F\u0430\u043C\u044F\u0442\u044C:
htmlManagerServlet.osTotalPageFile=\u0412\u0441\u0435\u0433\u043E \u0444\u0430\u0439\u043B\u043E\u0432\u044B\u0445 \u0441\u0442\u0440\u0430\u043D\u0438\u0446:
htmlManagerServlet.osFreePageFile=\u0421\u0432\u043E\u0431\u043E\u0434\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u043E\u0432\u044B\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B:
htmlManagerServlet.osMemoryLoad=\u041F\u0430\u043C\u044F\u0442\u0438 \u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043D\u043E:
htmlManagerServlet.osKernelTime=\u0412\u0440\u0435\u043C\u044F \u041E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0438 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0430 \u044F\u0434\u0440\u043E\u043C:
htmlManagerServlet.osUserTime=\u0412\u0440\u0435\u043C\u044F \u043E\u0431\u0440\u0430\u0431\u043E\u0442\u043A\u0438 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044F:
htmlManagerServlet.jvmFreeMemory=\u0421\u0432\u043E\u0431\u043E\u0434\u043D\u0430\u044F \u041F\u0430\u043C\u044F\u0442\u044C:
htmlManagerServlet.jvmMaxMemory=\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C \u043F\u0430\u043C\u044F\u0442\u0438:
htmlManagerServlet.jvmTotalMemory=\u0412\u0441\u044F \u043F\u0430\u043C\u044F\u0442\u044C:
htmlManagerServlet.jvmTableTitleMemoryPool=\u041E\u0431\u043B\u0430\u0441\u0442\u0438 \u043F\u0430\u043C\u044F\u0442\u0438
htmlManagerServlet.jvmTableTitleType=\u0422\u0438\u043F
htmlManagerServlet.jvmTableTitleInitial=\u0418\u0437\u043D\u0430\u0447\u0430\u043B\u044C\u043D\u043E
htmlManagerServlet.jvmTableTitleTotal=\u0412\u0441\u0435\u0433\u043E
htmlManagerServlet.jvmTableTitleMaximum=\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C
htmlManagerServlet.jvmTableTitleUsed=\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u0435\u0442\u0441\u044F
htmlManagerServlet.connectorStateMaxThreads=\u041C\u0430\u043A\u0441\u0438\u043C\u0443\u043C \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:
htmlManagerServlet.connectorStateThreadCount=\u041D\u044B\u043D\u0435\u0448\u043D\u0435\u0435 \u0447\u0438\u0441\u043B\u043E \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:
htmlManagerServlet.connectorStateThreadBusy=\u041D\u044B\u043D\u0435\u0448\u043D\u0435\u0435 \u0447\u0438\u0441\u043B\u043E \u0437\u0430\u043D\u044F\u0442\u044B\u0445 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432:
htmlManagerServlet.connectorStateAliveSocketCount=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0432\u0441\u0451 \u0435\u0449\u0451 \u0436\u0438\u0432\u044B\u0445 \u0441\u043E\u043A\u0435\u0442\u043E\u0432:
htmlManagerServlet.connectorStateMaxProcessingTime=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0440\u043D\u043E\u0435 \u0432\u0440\u0435\u043C\u044F:
htmlManagerServlet.connectorStateProcessingTime=\u041F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0440\u043D\u043E\u0435 \u0432\u0440\u0435\u043C\u044F:
htmlManagerServlet.connectorStateRequestCount=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432:
htmlManagerServlet.connectorStateErrorCount=\u041A\u043E\u043B\u0438\u0447\u0435\u0441\u0442\u0432\u043E \u043E\u0448\u0438\u0431\u043E\u043A:
htmlManagerServlet.connectorStateBytesRecieved=\u0411\u0430\u0439\u0442\u043E\u0432 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E:
htmlManagerServlet.connectorStateBytesSent=\u0411\u0430\u0439\u0442\u043E\u0432 \u043E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E:
htmlManagerServlet.connectorStateTableTittleStage=\u042D\u0442\u0430\u043F
htmlManagerServlet.connectorStateTableTittleTime=\u0412\u0440\u0435\u043C\u044F
htmlManagerServlet.connectorStateTableTittleBSent=\u0411 \u041E\u0442\u043F\u0440\u0432\u043B\u0435\u043D\u043E
htmlManagerServlet.connectorStateTableTittleBRecv=\u0411 \u041F\u043E\u043B\u0443\u0447\u0435\u043D\u043E
htmlManagerServlet.connectorStateTableTittleClientForw=\u041A\u043B\u0438\u0435\u043D\u0442 (\u041E\u0442\u043E\u0441\u043B\u0430\u043D\u044B\u0439)
htmlManagerServlet.connectorStateTableTittleClientAct=\u041A\u043B\u0438\u0435\u043D\u0442 (\u041D\u0430\u0441\u0442\u043E\u044F\u0449\u0438\u0439)
htmlManagerServlet.connectorStateTableTittleVHost=\u0412\u0425\u043E\u0441\u0442
htmlManagerServlet.connectorStateTableTittleRequest=\u0417\u0430\u043F\u0440\u043E\u0441\u044B
htmlManagerServlet.connectorStateHint=P: \u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044F \u0438 \u0433\u043E\u0442\u043E\u0432\u0438\u0442\u0441\u044F \u043A \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438 S: \u0421\u0435\u0440\u0432\u0438\u0441 F: \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u0438\u0435 R: \u0413\u043E\u0442\u043E\u0432 K: \u041F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C
......@@ -283,20 +283,59 @@ public class StatusManagerServlet
try {
// Display operating system statistics using APR if available
StatusTransformer.writeOSState(writer,mode);
args = new Object[7];
args[0] = sm.getString("htmlManagerServlet.osPhysicalMemory");
args[1] = sm.getString("htmlManagerServlet.osAvailableMemory");
args[2] = sm.getString("htmlManagerServlet.osTotalPageFile");
args[3] = sm.getString("htmlManagerServlet.osFreePageFile");
args[4] = sm.getString("htmlManagerServlet.osMemoryLoad");
args[5] = sm.getString("htmlManagerServlet.osKernelTime");
args[6] = sm.getString("htmlManagerServlet.osUserTime");
StatusTransformer.writeOSState(writer, mode, args);
// Display virtual machine statistics
StatusTransformer.writeVMState(writer,mode);
args = new Object[9];
args[0] = sm.getString("htmlManagerServlet.jvmFreeMemory");
args[1] = sm.getString("htmlManagerServlet.jvmTotalMemory");
args[2] = sm.getString("htmlManagerServlet.jvmMaxMemory");
args[3] = sm.getString("htmlManagerServlet.jvmTableTitleMemoryPool");
args[4] = sm.getString("htmlManagerServlet.jvmTableTitleType");
args[5] = sm.getString("htmlManagerServlet.jvmTableTitleInitial");
args[6] = sm.getString("htmlManagerServlet.jvmTableTitleTotal");
args[7] = sm.getString("htmlManagerServlet.jvmTableTitleMaximum");
args[8] = sm.getString("htmlManagerServlet.jvmTableTitleUsed");
// use StatusTransformer to output status
StatusTransformer.writeVMState(writer,mode, args);
Enumeration<ObjectName> enumeration = threadPools.elements();
while (enumeration.hasMoreElements()) {
ObjectName objectName = enumeration.nextElement();
String name = objectName.getKeyProperty("name");
args = new Object[19];
args[0] = sm.getString("htmlManagerServlet.connectorStateMaxThreads");
args[1] = sm.getString("htmlManagerServlet.connectorStateThreadCount");
args[2] = sm.getString("htmlManagerServlet.connectorStateThreadBusy");
args[3] = sm.getString("htmlManagerServlet.connectorStateAliveSocketCount");
args[4] = sm.getString("htmlManagerServlet.connectorStateMaxProcessingTime");
args[5] = sm.getString("htmlManagerServlet.connectorStateProcessingTime");
args[6] = sm.getString("htmlManagerServlet.connectorStateRequestCount");
args[7] = sm.getString("htmlManagerServlet.connectorStateErrorCount");
args[8] = sm.getString("htmlManagerServlet.connectorStateBytesRecieved");
args[9] = sm.getString("htmlManagerServlet.connectorStateBytesSent");
args[10] = sm.getString("htmlManagerServlet.connectorStateTableTitleStage");
args[11] = sm.getString("htmlManagerServlet.connectorStateTableTitleTime");
args[12] = sm.getString("htmlManagerServlet.connectorStateTableTitleBSent");
args[13] = sm.getString("htmlManagerServlet.connectorStateTableTitleBRecv");
args[14] = sm.getString("htmlManagerServlet.connectorStateTableTitleClientForw");
args[15] = sm.getString("htmlManagerServlet.connectorStateTableTitleClientAct");
args[16] = sm.getString("htmlManagerServlet.connectorStateTableTitleVHost");
args[17] = sm.getString("htmlManagerServlet.connectorStateTableTitleRequest");
args[18] = sm.getString("htmlManagerServlet.connectorStateHint");
// use StatusTransformer to output status
StatusTransformer.writeConnectorState
(writer, objectName,
name, mBeanServer, globalRequestProcessors,
requestProcessors, mode);
requestProcessors, mode, args);
}
if ((request.getPathInfo() != null)
......
......@@ -147,9 +147,10 @@ public class StatusTransformer {
*
* @param writer The output writer
* @param mode Mode <code>0</code> will generate HTML.
* Mode <code>1</code> will generate XML.
* Mode <code>1</code> will generate XML.
* @param args I18n labels for the OS state values
*/
public static void writeOSState(PrintWriter writer, int mode) {
public static void writeOSState(PrintWriter writer, int mode, Object[] args) {
long[] result = new long[16];
boolean ok = false;
try {
......@@ -172,20 +173,20 @@ public class StatusTransformer {
writer.print("<h1>OS</h1>");
writer.print("<p>");
writer.print(" Physical memory: ");
writer.print( args[0] );
writer.print(formatSize(Long.valueOf(result[0]), true));
writer.print(" Available memory: ");
writer.print(" " + args[1]);
writer.print(formatSize(Long.valueOf(result[1]), true));
writer.print(" Total page file: ");
writer.print(" " + args[2]);
writer.print(formatSize(Long.valueOf(result[2]), true));
writer.print(" Free page file: ");
writer.print(" " + args[3]);
writer.print(formatSize(Long.valueOf(result[3]), true));
writer.print(" Memory load: ");
writer.print(" " + args[4]);
writer.print(Long.valueOf(result[6]));
writer.print("<br>");
writer.print(" Process kernel time: ");
writer.print(" " + args[5]);
writer.print(formatTime(Long.valueOf(result[11] / 1000), true));
writer.print(" Process user time: ");
writer.print(" " + args[6]);
writer.print(formatTime(Long.valueOf(result[12] / 1000), true));
writer.print("</p>");
} else if (mode == 1){
......@@ -200,10 +201,11 @@ public class StatusTransformer {
* Write the VM state.
* @param writer The output writer
* @param mode Mode <code>0</code> will generate HTML.
* Mode <code>1</code> will generate XML.
* Mode <code>1</code> will generate XML.
* @param args I18n labels for the VM state values
* @throws Exception Propagated JMX error
*/
public static void writeVMState(PrintWriter writer, int mode)
public static void writeVMState(PrintWriter writer, int mode, Object[] args)
throws Exception {
SortedMap<String, MemoryPoolMXBean> memoryPoolMBeans = new TreeMap<>();
......@@ -216,18 +218,18 @@ public class StatusTransformer {
writer.print("<h1>JVM</h1>");
writer.print("<p>");
writer.print(" Free memory: ");
writer.print( args[0] );
writer.print(formatSize(
Long.valueOf(Runtime.getRuntime().freeMemory()), true));
writer.print(" Total memory: ");
writer.print(" " + args[1] );
writer.print(formatSize(
Long.valueOf(Runtime.getRuntime().totalMemory()), true));
writer.print(" Max memory: ");
writer.print(" " + args[2] );
writer.print(formatSize(
Long.valueOf(Runtime.getRuntime().maxMemory()), true));
writer.print("</p>");
writer.write("<table border=\"0\"><thead><tr><th>Memory Pool</th><th>Type</th><th>Initial</th><th>Total</th><th>Maximum</th><th>Used</th></tr></thead><tbody>");
writer.write("<table border=\"0\"><thead><tr><th>" + args[3] + "</th><th>" + args[4] + "</th><th>" + args[5] + "</th><th>" + args[6] + "</th><th>" + args[7] + "</th><th>" + args[8] + "</th></tr></thead><tbody>");
for (MemoryPoolMXBean memoryPoolMBean : memoryPoolMBeans.values()) {
MemoryUsage usage = memoryPoolMBean.getUsage();
writer.write("<tr><td>");
......@@ -283,13 +285,14 @@ public class StatusTransformer {
* @param globalRequestProcessors MBean names for the global request processors
* @param requestProcessors MBean names for the request processors
* @param mode Mode <code>0</code> will generate HTML.
* Mode <code>1</code> will generate XML.
* Mode <code>1</code> will generate XML.
* @param args I18n labels for the Connector state values
* @throws Exception Propagated JMX error
*/
public static void writeConnectorState(PrintWriter writer,
ObjectName tpName, String name, MBeanServer mBeanServer,
Vector<ObjectName> globalRequestProcessors,
Vector<ObjectName> requestProcessors, int mode) throws Exception {
Vector<ObjectName> requestProcessors, int mode, Object[] args) throws Exception {
if (mode == 0) {
writer.print("<h1>");
......@@ -297,15 +300,15 @@ public class StatusTransformer {
writer.print("</h1>");
writer.print("<p>");
writer.print(" Max threads: ");
writer.print( args[0] );
writer.print(mBeanServer.getAttribute(tpName, "maxThreads"));
writer.print(" Current thread count: ");
writer.print(" " + args[1]);
writer.print(mBeanServer.getAttribute(tpName, "currentThreadCount"));
writer.print(" Current thread busy: ");
writer.print(" " + args[2]);
writer.print(mBeanServer.getAttribute(tpName, "currentThreadsBusy"));
try {
Object value = mBeanServer.getAttribute(tpName, "keepAliveCount");
writer.print(" Keep alive sockets count: ");
writer.print(" " + args[3]);
writer.print(value);
} catch (Exception e) {
// Ignore
......@@ -328,25 +331,25 @@ public class StatusTransformer {
return;
}
writer.print(" Max processing time: ");
writer.print( args[4] );
writer.print(formatTime(mBeanServer.getAttribute
(grpName, "maxTime"), false));
writer.print(" Processing time: ");
writer.print(" " + args[5]);
writer.print(formatTime(mBeanServer.getAttribute
(grpName, "processingTime"), true));
writer.print(" Request count: ");
writer.print(" " + args[6]);
writer.print(mBeanServer.getAttribute(grpName, "requestCount"));
writer.print(" Error count: ");
writer.print(" " + args[7]);
writer.print(mBeanServer.getAttribute(grpName, "errorCount"));
writer.print(" Bytes received: ");
writer.print(" " + args[8]);
writer.print(formatSize(mBeanServer.getAttribute
(grpName, "bytesReceived"), true));
writer.print(" Bytes sent: ");
writer.print(" " + args[9]);
writer.print(formatSize(mBeanServer.getAttribute
(grpName, "bytesSent"), true));
writer.print("</p>");
writer.print("<table border=\"0\"><tr><th>Stage</th><th>Time</th><th>B Sent</th><th>B Recv</th><th>Client (Forwarded)</th><th>Client (Actual)</th><th>VHost</th><th>Request</th></tr>");
writer.print("<table border=\"0\"><tr><th>"+ args[10] + "</th><th>" + args[11] + "</th><th>" + args[12] +"</th><th>" + args[13] +"</th><th>" + args[14] + "</th><th>" + args[15] + "</th><th>" + args[16] + "</th><th>" + args[17] + "</th></tr>");
enumeration = requestProcessors.elements();
while (enumeration.hasMoreElements()) {
......@@ -361,7 +364,7 @@ public class StatusTransformer {
writer.print("</table>");
writer.print("<p>");
writer.print("P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive");
writer.print( args[18] );
writer.print("</p>");
} else if (mode == 1){
writer.write("<connector name='" + name + "'>");
......