You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/10/17 20:26:16 UTC

svn commit: r325950 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/portal/java/org/apache/cocoon/portlet/ src/java/org/apache/cocoon/servlet/

Author: vgritsenko
Date: Mon Oct 17 11:26:07 2005
New Revision: 325950

URL: http://svn.apache.org/viewcvs?rev=325950&view=rev
Log:
    <action dev="VG" type="fix" fixes-bug="35905">
      Do not flush and close output stream, servlet container
      will take care of it.
    </action>


Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java?rev=325950&r1=325949&r2=325950&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/CocoonPortlet.java Mon Oct 17 11:26:07 2005
@@ -1394,20 +1394,14 @@
                 getLogger().error("Cocoon got an Exception while trying to cleanup the uploaded files.", e);
             }
 
-            try {
-                OutputStream out = res.getPortletOutputStream();
-                out.flush();
-                out.close();
-            } catch (SocketException se) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("SocketException while trying to close stream.", se);
-                } else if (getLogger().isWarnEnabled()) {
-                    getLogger().warn("SocketException while trying to close stream.");
-                }
-
-            } catch (Exception e) {
-                getLogger().error("Cocoon got an Exception while trying to close stream.", e);
-            }
+            /*
+             * Portlet Specification 1.0, PLT.12.3.2 Output Stream and Writer Objects:
+             *   The termination of the render method of the portlet indicates
+             *   that the portlet has satisfied the request and that the output
+             *   object is to be closed.
+             *
+             * Portlet container will close the stream, no need to close it here.
+             */
         }
     }
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java?rev=325950&r1=325949&r2=325950&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portlet/ManagedCocoonPortlet.java Mon Oct 17 11:26:07 2005
@@ -667,20 +667,14 @@
                 ctxMap.clear();
             }
 
-            try {
-                OutputStream out = res.getPortletOutputStream();
-                out.flush();
-                out.close();
-            } catch (SocketException se) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("SocketException while trying to close stream.", se);
-                } else if (getLogger().isWarnEnabled()) {
-                    getLogger().warn("SocketException while trying to close stream.");
-                }
-
-            } catch (Exception e) {
-                getLogger().error("Cocoon got an Exception while trying to close stream.", e);
-            }
+            /*
+             * Portlet Specification 1.0, PLT.12.3.2 Output Stream and Writer Objects:
+             *   The termination of the render method of the portlet indicates
+             *   that the portlet has satisfied the request and that the output
+             *   object is to be closed.
+             *
+             * Portlet container will close the stream, no need to close it here.
+             */
         }
     }
 

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java?rev=325950&r1=325949&r2=325950&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/servlet/CocoonServlet.java Mon Oct 17 11:26:07 2005
@@ -1249,24 +1249,23 @@
                 getLogger().error("Cocoon got an Exception while trying to cleanup the uploaded files.", e);
             }
 
-            try {
-                OutputStream out = res.getOutputStream();
-                out.flush();
-                out.close();
-            } catch (SocketException se) {
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("SocketException while trying to close stream.", se);
-                } else if (getLogger().isWarnEnabled()) {
-                    getLogger().warn("SocketException while trying to close stream.");
-                }
-            } catch (IOException e) {
-                // See: http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107489037219505
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("IOException while trying to close stream.", e);
-                }
-            } catch (Exception e) {
-                getLogger().error("Exception while trying to close stream.", e);
-            }
+            /*
+             * Servlet Specification 2.2, 6.5 Closure of Response Object:
+             *
+             *   A number of events can indicate that the servlet has provided all of the
+             *   content to satisfy the request and that the response object can be
+             *   considered to be closed. The events are:
+             *     o The termination of the service method of the servlet.
+             *     o When the amount of content specified in the setContentLength method
+             *       of the response has been written to the response.
+             *     o The sendError method is called.
+             *     o The sendRedirect method is called.
+             *   When a response is closed, all content in the response buffer, if any remains,
+             *   must be immediately flushed to the client.
+             *
+             * Due to the above, out.flush() and out.close() are not necessary, and sometimes
+             * (if sendError or sendRedirect were used) request may be already closed.
+             */
         }
     }
 

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=325950&r1=325949&r2=325950&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Mon Oct 17 11:26:07 2005
@@ -175,9 +175,13 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="VG" type="fix" fixes-bug="35905">
+      Do not flush and close output stream, servlet container
+      will take care of it.
+    </action>
     <action dev="CZ" type="add">
-      Portal Block: Include coplet instance id in window renderer; ignore javascript: urls during
-                    url rewriting.
+      Portal Block: Include coplet instance id in window renderer; ignore
+      javascript: urls during url rewriting.
     </action>
     <action dev="RG" type="fix" fixes-bug="32784">
       Portal Block: Allow Full screen mode to show navigation.