pvillard31 commented on code in PR #11369:
URL: https://github.com/apache/nifi/pull/11369#discussion_r3472579929


##########
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:
   When readValue fails to parse, has the response stream already been 
consumed, so the body included in the error message would be empty?



-- 
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]

Reply via email to