Skip to content

Commit 566ea2a

Browse files
utils: read the full http response content & not just newline
Fix the code to read all of the json content and now just upto newline :facepalm: Signed-off-by: Rohit Yadav <[email protected]>
1 parent 61eeed4 commit 566ea2a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

utils/src/main/java/org/apache/cloudstack/utils/redfish/RedfishClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.security.NoSuchAlgorithmException;
3030
import java.util.Base64;
3131
import java.util.concurrent.TimeUnit;
32+
import java.util.stream.Collectors;
3233

3334
import javax.net.ssl.HostnameVerifier;
3435
import javax.net.ssl.HttpsURLConnection;
@@ -340,7 +341,7 @@ protected String processGetSystemIdResponse(CloseableHttpResponse response) {
340341
try {
341342
in = response.getEntity().getContent();
342343
BufferedReader streamReader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
343-
jsonString = streamReader.readLine();
344+
jsonString = streamReader.lines().collect(Collectors.joining());
344345
} catch (UnsupportedOperationException | IOException e) {
345346
throw new RedfishException("Failed to process system Response", e);
346347
}
@@ -384,8 +385,7 @@ protected RedfishPowerState processGetSystemRequestResponse(CloseableHttpRespons
384385
try {
385386
in = response.getEntity().getContent();
386387
BufferedReader streamReader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
387-
388-
jsonString = streamReader.readLine();
388+
jsonString = streamReader.lines().collect(Collectors.joining());
389389
String powerState = new JsonParser().parse(jsonString).getAsJsonObject().get(POWER_STATE).getAsString();
390390
return RedfishPowerState.valueOf(powerState);
391391
} catch (UnsupportedOperationException | IOException e) {

0 commit comments

Comments
 (0)