Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=43925
Add a new system property (org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE) to control the size of the buffer used by Jasper when buffering tag bodies.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.0.x/trunk@1821365 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/java/org/apache/jasper/runtime/BodyContentImpl.java b/java/org/apache/jasper/runtime/BodyContentImpl.java
index 0710081..1c35083 100644
--- a/java/org/apache/jasper/runtime/BodyContentImpl.java
+++ b/java/org/apache/jasper/runtime/BodyContentImpl.java
@@ -40,7 +40,12 @@
public class BodyContentImpl extends BodyContent {
private static final boolean LIMIT_BUFFER =
- Boolean.parseBoolean(System.getProperty("org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false"));
+ Boolean.parseBoolean(System.getProperty(
+ "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "false"));
+
+ private static final int TAG_BUFFER_SIZE =
+ Integer.getInteger("org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE",
+ Constants.DEFAULT_TAG_BUFFER_SIZE).intValue();
private char[] cb;
private int nextChar;
@@ -54,7 +59,7 @@
*/
public BodyContentImpl(JspWriter enclosingWriter) {
super(enclosingWriter);
- cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE];
+ cb = new char[TAG_BUFFER_SIZE];
bufferSize = cb.length;
nextChar = 0;
closed = false;
@@ -492,8 +497,8 @@
throw new IOException();
} else {
nextChar = 0;
- if (LIMIT_BUFFER && (cb.length > Constants.DEFAULT_TAG_BUFFER_SIZE)) {
- cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE];
+ if (LIMIT_BUFFER && (cb.length > TAG_BUFFER_SIZE)) {
+ cb = new char[TAG_BUFFER_SIZE];
bufferSize = cb.length;
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a71157e..bff7041 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -93,6 +93,12 @@
</subsection>
<subsection name="Jasper">
<changelog>
+ <add>
+ <bug>43925</bug>: Add a new system property
+ (<code>org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE</code>) to
+ control the size of the buffer used by Jasper when buffering tag bodies.
+ (markt)
+ </add>
<fix>
<bug>61854</bug>: When using sets and/or maps in EL expressions, ensure
that Jasper correctly parses the expression. Patch provided by Ricardo
diff --git a/webapps/docs/config/systemprops.xml b/webapps/docs/config/systemprops.xml
index 0680208..1a9fe3c 100644
--- a/webapps/docs/config/systemprops.xml
+++ b/webapps/docs/config/systemprops.xml
@@ -153,10 +153,17 @@
<code>true</code> will be used.</p>
</property>
+ <property name="org.apache.jasper.runtime. BodyContentImpl.BUFFER_SIZE">
+ <p>The size (in characters) to use when creating a tag buffer.</p>
+ <p>If not specified, the default value of
+ <code>org.apache.jasper.Constants.DEFAULT_TAG_BUFFER_SIZE</code> (512)
+ will be used.</p>
+ </property>
+
<property name="org.apache.jasper.runtime. BodyContentImpl.LIMIT_BUFFER">
<p>If <code>true</code>, any tag buffer that expands beyond
- <code>org.apache.jasper.Constants.DEFAULT_TAG_BUFFER_SIZE</code> will be
- destroyed and a new buffer created of the default size.</p>
+ <code>org.apache.jasper.runtime.BodyContentImpl.BUFFER_SIZE</code> will be
+ destroyed and a new buffer created.</p>
<p>If not specified, the default value of <code>false</code> will be used.</p>
</property>