Repository: cloudstack Updated Branches: refs/heads/master 7bbe7fc69 -> deeb754bf
Fixed Coverity Issues Reported Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/deeb754b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/deeb754b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/deeb754b Branch: refs/heads/master Commit: deeb754bfa5def465a2bf834fc8788698ef4da85 Parents: 7bbe7fc Author: Santhosh Edukulla <santhosh.eduku...@gmail.com> Authored: Fri Jul 25 16:42:14 2014 +0530 Committer: Santhosh Edukulla <santhosh.eduku...@gmail.com> Committed: Fri Jul 25 16:42:14 2014 +0530 ---------------------------------------------------------------------- .../src/com/cloud/api/doc/ApiXmlDocWriter.java | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/deeb754b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java index fe07056..6824185 100644 --- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java +++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java @@ -144,10 +144,8 @@ public class ApiXmlDocWriter { } for (String fileName : fileNames) { - try { - FileInputStream in = new FileInputStream(fileName); + try(FileInputStream in = new FileInputStream(fileName);) { preProcessedCommands.load(in); - in.close(); } catch (FileNotFoundException ex) { System.out.println("Can't find file " + fileName); System.exit(2); @@ -595,14 +593,17 @@ public class ApiXmlDocWriter { addDir(files[i], out); continue; } - FileInputStream in = new FileInputStream(files[i].getPath()); - out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length()))); - int len; - while ((len = in.read(tmpBuf)) > 0) { - out.write(tmpBuf, 0, len); + try(FileInputStream in = new FileInputStream(files[i].getPath());) { + out.putNextEntry(new ZipEntry(files[i].getPath().substring(pathToDir.length()))); + int len; + while ((len = in.read(tmpBuf)) > 0) { + out.write(tmpBuf, 0, len); + } + out.closeEntry(); + }catch(IOException ex) + { + s_logger.error("addDir:Exception:"+ ex.getMessage(),ex); } - out.closeEntry(); - in.close(); } } @@ -619,8 +620,7 @@ public class ApiXmlDocWriter { private static void writeAlertTypes(String dirName) { XStream xs = new XStream(); xs.alias("alert", Alert.class); - try { - ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName + "/alert_types.xml"), "alerts"); + try(ObjectOutputStream out = xs.createObjectOutputStream(new FileWriter(dirName + "/alert_types.xml"), "alerts");) { for (Field f : AlertManager.class.getFields()) { if (f.getClass().isAssignableFrom(Number.class)) { String name = f.getName().substring(11); @@ -628,7 +628,6 @@ public class ApiXmlDocWriter { out.writeObject(alert); } } - out.close(); } catch (IOException e) { s_logger.error("Failed to create output stream to write an alert types ", e); } catch (IllegalAccessException e) {