From 9320754402e40f66f240c6d0ff8de1632b0921ee Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 4 May 2011 19:53:54 +0000 Subject: [PATCH] Re-factor to try and determine if the root cause of https://issues.apache.org/bugzilla/show_bug.cgi?id=51124 is an OOME or something else. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099575 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/jasper/runtime/BodyContentImpl.java | 15 ++++++--------- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/java/org/apache/jasper/runtime/BodyContentImpl.java b/java/org/apache/jasper/runtime/BodyContentImpl.java index d9fb0f8a1..ef2d9ff86 100644 --- a/java/org/apache/jasper/runtime/BodyContentImpl.java +++ b/java/org/apache/jasper/runtime/BodyContentImpl.java @@ -56,8 +56,8 @@ public class BodyContentImpl extends BodyContent { */ public BodyContentImpl(JspWriter enclosingWriter) { super(enclosingWriter); - bufferSize = Constants.DEFAULT_TAG_BUFFER_SIZE; - cb = new char[bufferSize]; + cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE]; + bufferSize = cb.length; nextChar = 0; closed = false; } @@ -495,8 +495,8 @@ public class BodyContentImpl extends BodyContent { } else { nextChar = 0; if (LIMIT_BUFFER && (cb.length > Constants.DEFAULT_TAG_BUFFER_SIZE)) { - bufferSize = Constants.DEFAULT_TAG_BUFFER_SIZE; - cb = new char[bufferSize]; + cb = new char[Constants.DEFAULT_TAG_BUFFER_SIZE]; + bufferSize = cb.length; } } } @@ -644,13 +644,10 @@ public class BodyContentImpl extends BodyContent { len = cb.length; } - bufferSize = cb.length + len; - char[] tmp = new char[bufferSize]; - + char[] tmp = new char[cb.length + len]; System.arraycopy(cb, 0, tmp, 0, cb.length); cb = tmp; - tmp = null; - + bufferSize = cb.length; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 7792e81d3..3b3281b9c 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -172,6 +172,10 @@ Use a single TLD location cache for a web application rather than one per JSP compilation to speed up JSP compilation. (markt) + + 51124: Refactor BodyContentImpl to assist in determining the + root cause of this bug. Based on a patch by Ramiro. (markt) + -- 2.11.0