You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/01/23 09:55:05 UTC
[tomcat] branch 8.5.x updated: Fix: Add new connector attribute to
control facade recycling
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new af2d1be Fix: Add new connector attribute to control facade recycling
af2d1be is described below
commit af2d1beaf3ae1601d4938f2b7dbb1b74199be7d4
Author: remm <re...@apache.org>
AuthorDate: Thu Jan 23 10:54:52 2020 +0100
Fix: Add new connector attribute to control facade recycling
Use the same default as before, using the system property and false if
not set.
---
java/org/apache/catalina/connector/Connector.java | 37 ++++++++++++++++++-----
java/org/apache/catalina/connector/Response.java | 3 +-
webapps/docs/changelog.xml | 4 +++
webapps/docs/config/http.xml | 11 +++++++
webapps/docs/security-howto.xml | 10 +++---
5 files changed, 51 insertions(+), 14 deletions(-)
diff --git a/java/org/apache/catalina/connector/Connector.java b/java/org/apache/catalina/connector/Connector.java
index 1767199..b2f9ec4 100644
--- a/java/org/apache/catalina/connector/Connector.java
+++ b/java/org/apache/catalina/connector/Connector.java
@@ -57,13 +57,6 @@ public class Connector extends LifecycleMBeanBase {
private static final Log log = LogFactory.getLog(Connector.class);
- /**
- * Alternate flag to enable recycling of facades.
- */
- public static final boolean RECYCLE_FACADES =
- Boolean.parseBoolean(System.getProperty("org.apache.catalina.connector.RECYCLE_FACADES", "false"));
-
-
public static final String INTERNAL_EXECUTOR_NAME = "Internal";
@@ -154,6 +147,17 @@ public class Connector extends LifecycleMBeanBase {
/**
+ * The flag that controls recycling of the facades of the request
+ * processing objects. If set to <code>true</code> the object facades
+ * will be discarded when the request is recycled. If the security
+ * manager is enabled, this setting is ignored and object facades are
+ * always discarded.
+ */
+ protected boolean discardFacades =
+ Boolean.parseBoolean(System.getProperty("org.apache.catalina.connector.RECYCLE_FACADES", "false"));
+
+
+ /**
* The redirect port for non-SSL to SSL redirects.
*/
protected int redirectPort = 443;
@@ -390,6 +394,25 @@ public class Connector extends LifecycleMBeanBase {
/**
+ * @return <code>true</code> if the object facades are discarded, either
+ * when the discardFacades value is <code>true</code> or when the
+ * security manager is enabled.
+ */
+ public boolean getDiscardFacades() {
+ return discardFacades || Globals.IS_SECURITY_ENABLED;
+ }
+
+
+ /**
+ * Set the recycling strategy for the object facades.
+ * @param discardFacades the new value of the flag
+ */
+ public void setDiscardFacades(boolean discardFacades) {
+ this.discardFacades = discardFacades;
+ }
+
+
+ /**
* @return the "enable DNS lookups" flag.
*/
public boolean getEnableLookups() {
diff --git a/java/org/apache/catalina/connector/Response.java b/java/org/apache/catalina/connector/Response.java
index 7410d5a..47d3904 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.apache.catalina.Context;
-import org.apache.catalina.Globals;
import org.apache.catalina.Session;
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.SessionConfig;
@@ -233,7 +232,7 @@ public class Response implements HttpServletResponse {
isCharacterEncodingSet = false;
applicationResponse = null;
- if (Globals.IS_SECURITY_ENABLED || Connector.RECYCLE_FACADES) {
+ if (getRequest().getDiscardFacades()) {
if (facade != null) {
facade.clear();
facade = null;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index cf5b336..364bbc8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -127,6 +127,10 @@
<code>CachedResourceURLConnection</code>, it expands the feature to
include packedWARs and to take account of resource JARs. (markt)
</fix>
+ <update>
+ Refactor recycle facade system property into a new connector attribute
+ named <code>discardFacades</code>. (remm)
+ </update>
</changelog>
</subsection>
<subsection name="Coyote">
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index 3252eba..d8e6932 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -94,6 +94,17 @@
<code>_default_</code> will be used.</p>
</attribute>
+ <attribute name="discardFacades" required="false">
+ <p>A boolean value which can be used to enable or disable the recycling
+ of the facade objects that isolate the container internal request
+ processing objects. If set to <code>true</code> the facades will be
+ set for garbage collection after every request, otherwise they will be
+ reused. This setting has no effect when the security manager is enabled.
+ If not specified, this attribute is set to the value of the
+ <code>org.apache.catalina.connector.RECYCLE_FACADES</code> system
+ property, or <code>false</code> if not set.</p>
+ </attribute>
+
<attribute name="enableLookups" required="false">
<p>Set to <code>true</code> if you want calls to
<code>request.getRemoteHost()</code> to perform DNS lookups in
diff --git a/webapps/docs/security-howto.xml b/webapps/docs/security-howto.xml
index bd6ba71..16d685a 100644
--- a/webapps/docs/security-howto.xml
+++ b/webapps/docs/security-howto.xml
@@ -258,6 +258,11 @@
handle the response from a TRACE request (which exposes the browser to an
XSS attack), support for TRACE requests is disabled by default.</p>
+ <p>The <strong>discardFacades</strong> attribute set to <code>true</code>
+ will cause a new facade object to be created for each request. This
+ reduces the chances of a bug in an application exposing data from one
+ request to another.</p>
+
<p>The <strong>maxPostSize</strong> attribute controls the maximum size
of a POST request that will be parsed for parameters. The parameters are
cached for the duration of the request so this is limited to 2MB by
@@ -449,11 +454,6 @@
</section>
<section name="System Properties">
- <p>Setting <strong>org.apache.catalina.connector.RECYCLE_FACADES</strong>
- system property to <code>true</code> will cause a new facade object to be
- created for each request. This reduces the chances of a bug in an
- application exposing data from one request to another.</p>
-
<p>The <strong>
org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH</strong> and
<strong>org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH</strong>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org