cgenrich commented on code in PR #10326:
URL: https://github.com/apache/pinot/pull/10326#discussion_r1117621491
##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java:
##########
@@ -134,11 +137,23 @@ public Future<BrokerResponse> executeQueryAsync(String
brokerAddress, String que
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
+ LOGGER.debug("Sending query {} to {}", query, url);
+ return requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
+ .execute().toCompletableFuture().thenApply(httpResponse -> {
+ LOGGER.debug("Completed query, HTTP status is {}",
httpResponse.getStatusCode());
+
+ if (httpResponse.getStatusCode() != 200) {
+ throw new PinotClientException(
+ "Pinot returned HTTP status " + httpResponse.getStatusCode()
+ ", expected 200");
+ }
- Future<Response> response =
- requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
- .execute();
- return new BrokerResponseFuture(response, query, url,
_brokerReadTimeout);
+ String responseBody =
httpResponse.getResponseBody(StandardCharsets.UTF_8);
+ try {
+ return BrokerResponse.fromJson(OBJECT_READER.readTree(responseBody));
+ } catch (JsonProcessingException e) {
+ throw new CompletionException(e);
Review Comment:
@KKcorps The completable future will wrap exceptions other than
CompletionException.
In the past there would have been ExecutionException wrapping
JsonProcessingException.
Now, we'll have CompletionException wrapping JsonProcessingException,
however if I use CompletionException explicitly, we'll end up with
CompletionException wrapping ExecutionException wrapping
JsonProcessingException.
I thought avoiding one level of wrapping would be preferred since there will
be a change in the hierarchy regardless.
Please advise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]