You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2009/04/09 17:11:46 UTC

svn commit: r763681 - /tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java

Author: markt
Date: Thu Apr  9 15:11:46 2009
New Revision: 763681

URL: http://svn.apache.org/viewvc?rev=763681&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46354
ArrayIndexOutOfBoundsException when using org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true
Pathc provided by Konstantin Kolinko

Modified:
    tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java

Modified: tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java?rev=763681&r1=763680&r2=763681&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java Thu Apr  9 15:11:46 2009
@@ -51,9 +51,6 @@
     // Enclosed writer to which any output is written
     private Writer writer;
     
-    // See comment in setWriter()
-    private int bufferSizeSave;
-    
     /**
      * Constructor.
      */
@@ -508,6 +505,19 @@
     }
     
     /**
+     * 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();
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org