Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Brooks committed Oct 16, 2024
1 parent 2f4adfe commit 29ec410
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testBulkRequestBodyImproperlyTerminated() throws IOException {
);
ResponseException responseException = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request));
assertEquals(400, responseException.getResponse().getStatusLine().getStatusCode());
assertThat(responseException.getMessage(), containsString("could not parse bulk request body"));
assertThat(responseException.getMessage(), containsString("The bulk request must be terminated by a newline"));
}

public void testBulkRequest() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,13 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
}
}

private static ElasticsearchParseException parseFailureException(Exception e) {
return new ElasticsearchParseException("could not parse bulk request body", e);
private static Exception parseFailureException(Exception e) {
if (e instanceof IllegalArgumentException) {
return e;
} else {
// TODO: Maybe improve in follow-up to be XContentParseException and include line number and column
return new ElasticsearchParseException("could not parse bulk request body", e);
}
}

static class ChunkHandler implements BaseRestHandler.RequestBodyChunkConsumer {
Expand Down

0 comments on commit 29ec410

Please sign in to comment.