svn commit: r1351999 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1351999 - /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java

jacopoc
Author: jacopoc
Date: Wed Jun 20 09:00:26 2012
New Revision: 1351999

URL: http://svn.apache.org/viewvc?rev=1351999&view=rev
Log:
When an IOException error happens while communicating with the browser (for example when the user closes the browser window before the page is returned) there is no need to attempt to render the error page; this was causing two error stack traces in the logs every time a connection was aborted; improved logging for this event.


Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1351999&r1=1351998&r2=1351999&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Wed Jun 20 09:00:26 2012
@@ -224,10 +224,17 @@ public class ControlServlet extends Http
             requestHandler.doRequest(request, response, null, userLogin, delegator);
         } catch (RequestHandlerException e) {
             Throwable throwable = e.getNested() != null ? e.getNested() : e;
-            Debug.logError(throwable, "Error in request handler: ", module);
-            StringUtil.HtmlEncoder encoder = new StringUtil.HtmlEncoder();
-            request.setAttribute("_ERROR_MESSAGE_", encoder.encode(throwable.toString()));
-            errorPage = requestHandler.getDefaultErrorPage(request);
+            if (throwable instanceof IOException) {
+                // when an IOException occurs (most of the times caused by the browser window being closed before the request is completed)
+                // the connection with the browser is lost and so there is no need to serve the error page; a message is logged to record the event
+                if (Debug.warningOn()) Debug.logWarning("Communication error with the client while processing the request: " + request.getAttribute("_CONTROL_PATH_") + request.getPathInfo(), module);
+                if (Debug.verboseOn()) Debug.logVerbose(throwable, module);
+            } else {
+                Debug.logError(throwable, "Error in request handler: ", module);
+                StringUtil.HtmlEncoder encoder = new StringUtil.HtmlEncoder();
+                request.setAttribute("_ERROR_MESSAGE_", encoder.encode(throwable.toString()));
+                errorPage = requestHandler.getDefaultErrorPage(request);
+            }
         } catch (Exception e) {
             Debug.logError(e, "Error in request handler: ", module);
             StringUtil.HtmlEncoder encoder = new StringUtil.HtmlEncoder();