Skip to content

Commit

Permalink
fix: NPE caused by error handling code (#1925)
Browse files Browse the repository at this point in the history
  • Loading branch information
koebi authored Dec 3, 2024
2 parents ce59c65 + 78c9e77 commit b95a1c8
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RELEASING:
### Removed

### Fixed
- NPE in error handling ([#1925](https://github.com/GIScience/openrouteservice/pull/1925))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
return errorHandler.handleStatusCodeException(new ParameterValueException(ExportErrorCodes.MISMATCHED_INPUT, exception.getPath().get(0).getFieldName()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
if (e.getLocalizedMessage() != null && e.getLocalizedMessage().startsWith("Required request body is missing")) {
return errorHandler.handleStatusCodeException(new EmptyElementException(ExportErrorCodes.MISSING_PARAMETER, "Request body could not be read"));
}
return errorHandler.handleGenericException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
return errorHandler.handleStatusCodeException(new ParameterValueException(IsochronesErrorCodes.INVALID_PARAMETER_FORMAT, exception.getPath().get(0).getFieldName()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
if (e.getLocalizedMessage() != null && e.getLocalizedMessage().startsWith("Required request body is missing")) {
return errorHandler.handleStatusCodeException(new EmptyElementException(IsochronesErrorCodes.MISSING_PARAMETER, "Request body could not be read"));
}
return errorHandler.handleGenericException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
return errorHandler.handleStatusCodeException(new ParameterValueException(MatrixErrorCodes.INVALID_PARAMETER_FORMAT, exception.getPath().get(0).getFieldName()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
if (e.getLocalizedMessage() != null && e.getLocalizedMessage().startsWith("Required request body is missing")) {
return errorHandler.handleStatusCodeException(new EmptyElementException(MatrixErrorCodes.MISSING_PARAMETER, "Request body could not be read"));
}
return errorHandler.handleGenericException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
return errorHandler.handleStatusCodeException(new ParameterValueException(RoutingErrorCodes.INVALID_PARAMETER_FORMAT, exception.getPath().get(0).getFieldName()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
if (e.getLocalizedMessage() != null && e.getLocalizedMessage().startsWith("Required request body is missing")) {
return errorHandler.handleStatusCodeException(new EmptyElementException(RoutingErrorCodes.MISSING_PARAMETER, "Request body could not be read"));
}
return errorHandler.handleGenericException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public ResponseEntity<Object> handleReadingBodyException(final Exception e) {
return errorHandler.handleStatusCodeException(new ParameterValueException(SnappingErrorCodes.INVALID_PARAMETER_VALUE, (String) exception.getValue()));
} else {
// Check if we are missing the body as a whole
if (e.getLocalizedMessage().startsWith("Required request body is missing")) {
if (e.getLocalizedMessage() != null && e.getLocalizedMessage().startsWith("Required request body is missing")) {
return errorHandler.handleStatusCodeException(new EmptyElementException(SnappingErrorCodes.MISSING_PARAMETER, "Request body could not be read"));
}
return errorHandler.handleGenericException(e);
Expand Down

0 comments on commit b95a1c8

Please sign in to comment.