I am coding a download file controller
Sometime user will close the browser window before the file is fully written. - which is cool.
The problem is that my logs are full of this error:
org.apache.catalina.connector.ClientAbortException: java.io.IOException: An established connection was aborted by the software in your host machine at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:333) at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:758) at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:663) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:368) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:346) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2147) at org.apache.commons.io.IOUtils.copy(IOUtils.java:2102) at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123) at org.apache.commons.io.IOUtils.copy(IOUtils.java:2078)
When I am trying to catch only this specific error eclipse is saying:
ClientAbortException cannot be resolved to a type
I have the project setup and running correctly so is it possible to catch only this specific exception:
org.apache.catalina.connector.ClientAbortException
I would like to keep the IOException in case of another catastrophe.

The ClientAbortException is derived from IOException. You have to inspect exactly what exception caused the IOException e:
...
} catch (FileNotFoundException fnfe) {
// ... handle FileNotFoundException
} catch (IOException e) {
String exceptionSimpleName = e.getCause().getClass().getSimpleName();
if ("ClientAbortException".equals(exceptionSimpleName)) {
// ... handle ClientAbortException
} else {
// ... handle general IOException or another cause
}
}
return null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With