From 7307168218329e15626a7515ca1fb3e7cee906f3 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 21 Sep 2017 15:58:47 +0530 Subject: [PATCH] cloudian: more npe fixes, around response contents (this needs fixing) Signed-off-by: Rohit Yadav --- .../src/com/cloudian/cloudstack/CloudianClient.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/integrations/cloudian/src/com/cloudian/cloudstack/CloudianClient.java b/plugins/integrations/cloudian/src/com/cloudian/cloudstack/CloudianClient.java index 3f7c9f0d49b..170f22a954f 100644 --- a/plugins/integrations/cloudian/src/com/cloudian/cloudstack/CloudianClient.java +++ b/plugins/integrations/cloudian/src/com/cloudian/cloudstack/CloudianClient.java @@ -145,6 +145,9 @@ public class CloudianClient { try { final HttpResponse response = get(String.format("/user/list?groupId=%s&userType=all&userStatus=active", groupId)); final ObjectMapper mapper = new ObjectMapper(); + if (response.getEntity() == null || response.getEntity().getContent() == null) { + return null; + } return Arrays.asList(mapper.readValue(response.getEntity().getContent(), UserInfo[].class)); } catch (final IOException e) { LOG.error("Failed to list Cloudian users due to:", e); @@ -187,6 +190,9 @@ public class CloudianClient { try { final HttpResponse response = get(String.format("/group?groupId=%s", groupId)); final ObjectMapper mapper = new ObjectMapper(); + if (response.getEntity() == null || response.getEntity().getContent() == null) { + return null; + } return mapper.readValue(response.getEntity().getContent(), GroupInfo.class); } catch (final IOException e) { LOG.error("Failed to list Cloudian group due to:", e);