Fix owprov API handler /inventory/<serial>?rrmSettings=true (#127)

Signed-off-by: Jeffrey Han <39203126+elludraon@users.noreply.github.com>
This commit is contained in:
Jeffrey Han
2022-11-14 11:00:23 -08:00
committed by GitHub
parent c1511e8e91
commit ea3a13e98c

View File

@@ -690,6 +690,19 @@ public class UCentralClient {
try {
return gson.fromJson(response.getBody(), RRMDetails.class);
} catch (JsonSyntaxException e) {
// catch strings like "no", "inherit", "invalid" (???)
JSONObject respBody;
try {
respBody = new JSONObject(response.getBody());
respBody.getString("rrm");
logger.error(
"RRMDetails returned unexpected string body: {}",
respBody
);
return null;
} catch (JSONException e2) { /* ignore and fall through */}
// otherwise, log as a deserialization error
String errMsg = String.format(
"Failed to deserialize to RRMDetails: %s",
response.getBody()