Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of exception handler trying to write response to a disconnected c… #109

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.catalina.connector.ClientAbortException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
Expand All @@ -35,7 +36,6 @@
import jakarta.servlet.http.HttpServletRequest;

@RestControllerAdvice
@Order(ValidationExceptionMapper.ORDER + 1)
public class ApplicationExceptionMapper {

private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationExceptionMapper.class);
Expand All @@ -53,7 +53,16 @@ public class ApplicationExceptionMapper {
EXCEPTION_STATUS_MAP.put(NoResourceFoundException.class, HttpStatus.NOT_FOUND);
}

@ExceptionHandler(ClientAbortException.class)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the build failure, Probably a testcase is failing

@Order(ValidationExceptionMapper.ORDER + 1)
public void handleClientAborted(
HttpServletRequest request, ClientAbortException clientAbortException) {
logException(
request, clientAbortException); // socket closed, cannot return any error response
}

@ExceptionHandler(Throwable.class)
@Order(ValidationExceptionMapper.ORDER + 2)
public ResponseEntity<ErrorResponse> handleAll(HttpServletRequest request, Throwable th) {
logException(request, th);

Expand Down
Loading