From e0ba5302b66283c56819c49786d75f2f0bb53873 Mon Sep 17 00:00:00 2001 From: Kshitij Kansal Date: Thu, 30 Jul 2015 16:23:50 +0530 Subject: [PATCH] CLOUDSTACK-8692: Resource leak found by the internal coverity instance at Citrix fixed. --- .../org/apache/cloudstack/region/RegionsApiUtil.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java index 92c5ed4e17ef..7fbcfa0795ed 100644 --- a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java +++ b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java @@ -186,8 +186,12 @@ protected static UserAccount makeUserAccountAPICall(Region region, String comman XStream xstream = new XStream(new DomDriver()); xstream.alias("useraccount", UserAccountVO.class); xstream.aliasField("id", UserAccountVO.class, "uuid"); - ObjectInputStream in = xstream.createObjectInputStream(is); - return (UserAccountVO)in.readObject(); + try(ObjectInputStream in = xstream.createObjectInputStream(is);) { + return (UserAccountVO)in.readObject(); + } catch (IOException e) { + s_logger.error(e.getMessage()); + return null; + } } else { return null; } @@ -304,4 +308,4 @@ private static String signRequest(String request, String key) { } } -} \ No newline at end of file +}