You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2007/04/03 16:00:11 UTC
svn commit: r525157 -
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java
Author: knopp
Date: Tue Apr 3 07:00:10 2007
New Revision: 525157
URL: http://svn.apache.org/viewvc?view=rev&rev=525157
Log:
Fixed bug with Jetty 6 and EofException
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java?view=diff&rev=525157&r1=525156&r2=525157
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Response.java Tue Apr 3 07:00:10 2007
@@ -232,6 +232,56 @@
public abstract void write(final CharSequence string);
/**
+ * Either throws the exception wrapped as {@link WicketRuntimeException} or
+ * silently ignores it. This method should ignore IO related exceptions like
+ * connection reset by peer or broken pipe.
+ *
+ * @param e
+ */
+ private void handleException(Exception e) {
+ // FIXME this doesn't catch all. For instance, Jetty (6/ NIO) on
+ // Unix like platforms will not be recogninzed as exceptions
+ // that should be ignored
+ Throwable throwable = e;
+ boolean ignoreException = false;
+ while (throwable != null)
+ {
+ if (throwable instanceof SQLException)
+ {
+ break; // leave false and quit loop
+ }
+ else if (throwable instanceof SocketException)
+ {
+ String message = throwable.getMessage();
+ ignoreException = message != null
+ && (message.indexOf("Connection reset") != -1
+ || message.indexOf("Broken pipe") != -1
+ || message.indexOf("Socket closed") != -1
+ || message.indexOf("connection abort") != -1);
+ }
+ else
+ {
+ ignoreException = throwable.getClass().getName().indexOf("ClientAbortException") >= 0
+ || throwable.getClass().getName().indexOf("EofException") >= 0;
+ }
+ if (ignoreException)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Socket exception ignored for sending Resource "
+ + "response to client (ClientAbort)", e);
+ }
+ break;
+ }
+ throwable = throwable.getCause();
+ }
+ if (!ignoreException)
+ {
+ throw new WicketRuntimeException("Unable to write the response", e);
+ }
+ }
+
+ /**
* Copies the given input stream to the servlet response
* <p>
* NOTE Content-Length is not set because it would require to buffer the
@@ -252,47 +302,7 @@
}
catch (Exception e)
{
- // FIXME this doesn't catch all. For instance, Jetty (6/ NIO) on
- // Unix like platforms will not be recogninzed as exceptions
- // that should be ignored
-
- Throwable throwable = e;
- boolean ignoreException = false;
- while (throwable != null)
- {
- if (throwable instanceof SQLException)
- {
- break; // leave false and quit loop
- }
- else if (throwable instanceof SocketException)
- {
- String message = throwable.getMessage();
- ignoreException = message != null
- && (message.indexOf("Connection reset") != -1
- || message.indexOf("Broken pipe") != -1
- || message.indexOf("Socket closed") != -1
- || message.indexOf("connection abort") != -1);
- }
- else
- {
- ignoreException = throwable.getClass().getName()
- .indexOf("ClientAbortException") >= 0;
- }
- if (ignoreException)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Socket exception ignored for sending Resource "
- + "response to client (ClientAbort)", e);
- }
- break;
- }
- throwable = throwable.getCause();
- }
- if (!ignoreException)
- {
- throw new WicketRuntimeException("Unable to write the response", e);
- }
+ handleException(e);
}
finally
{
@@ -305,7 +315,8 @@
}
catch (IOException e)
{
- throw new WicketRuntimeException(e);
+ // jetty 6 throws broken pipe exception here too
+ handleException(e);
}
}
}