Skip to content

Commit

Permalink
Update JsonMappingExceptionMapper “Early EOF” logic
Browse files Browse the repository at this point in the history
  • Loading branch information
eager-signal committed May 1, 2024
1 parent dcfca4d commit cf307db
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
import com.fasterxml.jackson.databind.JsonMappingException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import java.util.concurrent.TimeoutException;

public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
@Override
public Response toResponse(final JsonMappingException exception) {
if (exception.getCause() instanceof TimeoutException) {
if (exception.getCause() instanceof java.util.concurrent.TimeoutException) {
return Response.status(Response.Status.REQUEST_TIMEOUT).build();
}
if ("Early EOF".equals(exception.getMessage())) {
if (exception.getCause() instanceof org.eclipse.jetty.io.EofException
|| exception.getMessage() != null && exception.getMessage().startsWith("Early EOF")) {
// Some sort of timeout or broken connection
return Response.status(Response.Status.BAD_REQUEST).build();
}
Expand Down

0 comments on commit cf307db

Please sign in to comment.