tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1037794 - in /tomcat/trunk/java/org/apache/jasper/runtime: BodyContentImpl.java PageContextImpl.java
Date Mon, 22 Nov 2010 17:40:09 GMT
Author: kkolinko
Date: Mon Nov 22 17:40:09 2010
New Revision: 1037794

URL: http://svn.apache.org/viewvc?rev=1037794&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50228
Improve recycling of BodyContentImpl.

Modified:
    tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java
    tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.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=1037794&r1=1037793&r2=1037794&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/BodyContentImpl.java Mon Nov 22 17:40:09 2010
@@ -605,7 +605,27 @@ public class BodyContentImpl extends Bod
             clearBody();
         }
     }
-    
+
+    /**
+     * This method shall "reset" the internal state of a BodyContentImpl,
+     * releasing all internal references, and preparing it for potential
+     * reuse by a later invocation of {@link PageContextImpl#pushBody(Writer)}.
+     *
+     * <p>Note, that BodyContentImpl instances are usually owned by a
+     * PageContextImpl instance, and PageContextImpl instances are recycled
+     * and reused.
+     *
+     * @see PageContextImpl#release()
+     */
+    protected void recycle() {
+        this.writer = null;
+        try {
+            this.clear();
+        } catch (IOException ex) {
+            // ignore
+        }
+    }
+
     private void ensureOpen() throws IOException {
         if (closed) throw new IOException("Stream closed");
     }

Modified: tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java?rev=1037794&r1=1037793&r2=1037794&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/PageContextImpl.java Mon Nov 22 17:40:09 2010
@@ -204,6 +204,9 @@ public class PageContextImpl extends Pag
             baseOut.recycle();
             session = null;
             attributes.clear();
+            for (BodyContentImpl body: outs) {
+                body.recycle();
+            }
         }
     }
 



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


Mime
View raw message