exceptionfactory commented on code in PR #11369:
URL: https://github.com/apache/nifi/pull/11369#discussion_r3474747592
##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/main/java/org/apache/nifi/snowflake/service/SnowpipeIngestClient.java:
##########
@@ -135,26 +135,34 @@ InsertReport getInsertReport() {
final URI requestUri = appendRequestId(insertReportUri);
final String authorization =
authorizationProvider.getRequestAuthorization().authorization();
- final HttpRequest request = HttpRequest.newBuilder()
- .uri(requestUri)
- .header(AUTHORIZATION_HEADER, authorization)
- .header(ACCEPT_HEADER, APPLICATION_JSON)
- .GET()
- .build();
-
- final HttpResponse<String> response = sendRequest(request);
- final int statusCode = response.statusCode();
- final String responseBody = response.body();
- if (statusCode == HttpURLConnection.HTTP_OK) {
- try {
- return objectMapper.readValue(responseBody,
InsertReport.class);
- } catch (final JsonProcessingException e) {
- final String message = "Insert Report [%s] response parsing
failed [%s]".formatted(requestUri, responseBody);
- throw new SnowpipeResponseException(message, e);
+ try (
+ HttpResponseEntity responseEntity = webClientService.get()
+ .uri(requestUri)
+ .header(AUTHORIZATION_HEADER, authorization)
+ .header(ACCEPT_HEADER, APPLICATION_JSON)
+ .retrieve();
+ InputStream responseBodyStream = responseEntity.body()
+ ) {
+ final int statusCode = responseEntity.statusCode();
+ if (statusCode == HttpURLConnection.HTTP_OK) {
+ try {
+ return objectMapper.readValue(responseBodyStream,
InsertReport.class);
+ } catch (final JsonProcessingException e) {
+ final byte[] responseBodyBytes =
responseBodyStream.readAllBytes();
Review Comment:
Good catch, thanks! I pushed an update to read the response body as a string
regardless of status code.
--
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]