7

I am having following exception for application deployed at Jboss, Browser is IE8

2012-03-19 09:17:12,014 WARN  [org.apache.catalina.core.ContainerBase.jboss.web].         [localhost]] Exception Processing ErrorPage[errorCode=404, location=/internalError.jsp]
ClientAbortException:  java.net.SocketException: Broken pipe
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:327)

It seems that browser closed the socket before server writes internalError.jsp to it. Please suggest how to solve it , or atleast how I can hide this exception.

Thanks Hikumar

HKumar
  • 655
  • 1
  • 8
  • 18

1 Answers1

20

You cannot solve it. You cannot control whether the client will press Esc, or hastily click a different link, or close the browser, or have its machine crashed, etcetera, while your server is still handling the HTTP request/response.

You can "hide" it by a global filter (mapped on /*) which does something like this:

try {
    chain.doFilter(request, response);
}
catch (ClientAbortException e) {
    // Ignore.
}

This however brings a servletcontainer-specfic dependency in your code. The filter in question would result in NoClassDefFoundError on a servletcontainer of a different make which doesn't use Tomcat specific ClientAbortException. You might want to check the class simple name instead. Make use of the advantage that it's a subclass of IOException:

try {
    chain.doFilter(request, response);
}
catch (IOException e) {
    if (!e.getClass().getSimpleName().equals("ClientAbortException")) {
        throw e;
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Its coming even without pressing stop or closing browser or or hastily clicking a different link, May be something with Internet Explorer, I will give a try to your solution, Still if you have any other solution which required very few changes i.e some configuration etc, please share Thanks – HKumar Mar 20 '12 at 17:54
  • 1
    Are there instances where a ClientAbortException is thrown in which you wouldn't want to ignore it? That is, would it be a good idea to at least log.debug or log.info it? – riddle_me_this Jul 20 '15 at 01:45