Author: mmillson
Date: 2009-05-28 11:28:37 -0400 (Thu, 28 May 2009)
New Revision: 1072
Modified:
branches/JBOSSWEB_2_0_0_GA_JBPAPP-2040/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java
Log:
Fix fix LIMIT_BUFFER=true ArrayIndexOutOfBoundsException for [JBPAPP-2040].
Modified:
branches/JBOSSWEB_2_0_0_GA_JBPAPP-2040/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_JBPAPP-2040/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java 2009-05-28
14:33:59 UTC (rev 1071)
+++
branches/JBOSSWEB_2_0_0_GA_JBPAPP-2040/src/share/classes/org/apache/jasper/runtime/BodyContentImpl.java 2009-05-28
15:28:37 UTC (rev 1072)
@@ -51,9 +51,6 @@
// Enclosed writer to which any output is written
private Writer writer;
- // See comment in setWriter()
- private int bufferSizeSave;
-
/**
* Constructor.
*/
@@ -506,8 +503,21 @@
closed = true;
}
}
-
+
/**
+ * This method returns the size of the buffer used by the JspWriter.
+ *
+ * @return the size of the buffer in bytes, or 0 is unbuffered.
+ */
+ public int getBufferSize() {
+ // According to the spec, the JspWriter returned by
+ // JspContext.pushBody(java.io.Writer writer) must behave as
+ // though it were unbuffered. This means that its getBufferSize()
+ // must always return 0.
+ return (writer == null) ? bufferSize : 0;
+ }
+
+ /**
* @return the number of bytes unused in the buffer
*/
public int getRemaining() {
@@ -558,22 +568,7 @@
void setWriter(Writer writer) {
this.writer = writer;
closed = false;
- if (writer != null) {
- // According to the spec, the JspWriter returned by
- // JspContext.pushBody(java.io.Writer writer) must behave as
- // though it were unbuffered. This means that its getBufferSize()
- // must always return 0. The implementation of
- // JspWriter.getBufferSize() returns the value of JspWriter's
- // 'bufferSize' field, which is inherited by this class.
- // Therefore, we simply save the current 'bufferSize' (so we can
- // later restore it should this BodyContentImpl ever be reused by
- // a call to PageContext.pushBody()) before setting it to 0.
- if (bufferSize != 0) {
- bufferSizeSave = bufferSize;
- bufferSize = 0;
- }
- } else {
- bufferSize = bufferSizeSave;
+ if (writer == null) {
clearBody();
}
}