I'm currently working on the image delivery process for our clients. In the event of a client disconnect without receiving the image, Spring triggers an exception (org.apache.catalina.connector.ClientAbortException). To manage this, our error handling mechanism intercepts the exception and attempts to return an (ApiErrorResponse) value.
However, a challenge arises as the socket is already closed, leading to Tomcat throwing an IOException when trying to write to the closed socket.
I've addressed this issue with the following solution ( If anyone needed ). Do you have any suggestions for a more appropriate resolution, or is this approach the recommended way to address the problem?
Thank you.
@ControllerAdvice
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class FallbackExceptionHandler extends ErrorHandlingControllerAdvice {
public FallbackExceptionHandler(List<ApiExceptionHandler> handlers, FallbackApiExceptionHandler fallbackHandler, LoggingService loggingService, List<ApiErrorResponseCustomizer> responseCustomizers) {
super(handlers, fallbackHandler, loggingService, responseCustomizers);
}
@ExceptionHandler
public void handleException(ClientAbortException exception) {
// do nothing
}
}
Hello,
I'm currently working on the image delivery process for our clients. In the event of a client disconnect without receiving the image, Spring triggers an exception (org.apache.catalina.connector.ClientAbortException). To manage this, our error handling mechanism intercepts the exception and attempts to return an (ApiErrorResponse) value.
However, a challenge arises as the socket is already closed, leading to Tomcat throwing an IOException when trying to write to the closed socket.
I've addressed this issue with the following solution ( If anyone needed ). Do you have any suggestions for a more appropriate resolution, or is this approach the recommended way to address the problem?
Thank you.