Skip to content

Commit

Permalink
Remove custom handling of MaxUploadSizeExceededException as this is…
Browse files Browse the repository at this point in the history
… now handled properly by Spring 6 itself. See spring-projects/spring-framework#27170
  • Loading branch information
tdonohue committed Mar 8, 2024
1 parent 819cfa4 commit 56e326b
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

Expand Down Expand Up @@ -99,13 +98,6 @@ protected void handleWrongRequestException(HttpServletRequest request, HttpServl
sendErrorResponse(request, response, ex, "Request is invalid or incorrect", HttpServletResponse.SC_BAD_REQUEST);
}

@ExceptionHandler(MaxUploadSizeExceededException.class)
protected void handleMaxUploadSizeExceededException(HttpServletRequest request, HttpServletResponse response,
Exception ex) throws IOException {
sendErrorResponse(request, response, ex, "Request entity is too large",
HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
}

@ExceptionHandler(SQLException.class)
protected void handleSQLException(HttpServletRequest request, HttpServletResponse response, Exception ex)
throws IOException {
Expand Down Expand Up @@ -188,7 +180,7 @@ protected void handleCustomUnprocessableEntityException(HttpServletRequest reque
@ExceptionHandler(QueryMethodParameterConversionException.class)
protected void ParameterConversionException(HttpServletRequest request, HttpServletResponse response, Exception ex)
throws IOException {
// we want the 400 status for missing parameters, see https://jira.lyrasis.org/browse/DS-4428
// we want the 400 status for missing parameters, see https://github.com/DSpace/DSpace/issues/7765
sendErrorResponse(request, response, ex,
"A required parameter is invalid",
HttpStatus.BAD_REQUEST.value());
Expand All @@ -197,7 +189,7 @@ protected void ParameterConversionException(HttpServletRequest request, HttpServ
@ExceptionHandler(MissingParameterException.class)
protected void MissingParameterException(HttpServletRequest request, HttpServletResponse response, Exception ex)
throws IOException {
// we want the 400 status for missing parameters, see https://jira.lyrasis.org/browse/DS-4428
// we want the 400 status for missing parameters, see https://github.com/DSpace/DSpace/issues/7765
sendErrorResponse(request, response, ex,
"A required parameter is missing",
HttpStatus.BAD_REQUEST.value());
Expand All @@ -219,14 +211,14 @@ protected void handleInvalidCaptchaTokenRequestException(HttpServletRequest requ
protected ResponseEntity<Object> handleMissingServletRequestParameter(MissingServletRequestParameterException ex,
HttpHeaders headers, HttpStatusCode status,
WebRequest request) {
// we want the 400 status for missing parameters, see https://jira.lyrasis.org/browse/DS-4428
// we want the 400 status for missing parameters, see https://github.com/DSpace/DSpace/issues/7765
return super.handleMissingServletRequestParameter(ex, headers, HttpStatus.BAD_REQUEST, request);
}

@Override
protected ResponseEntity<Object> handleTypeMismatch(TypeMismatchException ex, HttpHeaders headers,
HttpStatusCode status, WebRequest request) {
// we want the 400 status for missing parameters, see https://jira.lyrasis.org/browse/DS-4428
// we want the 400 status for missing parameters, see https://github.com/DSpace/DSpace/issues/7765
return super.handleTypeMismatch(ex, headers, HttpStatus.BAD_REQUEST, request);
}

Expand Down

0 comments on commit 56e326b

Please sign in to comment.