ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abaranc...@apache.org
Subject [1/2] ambari git commit: AMBARI-11991 - Fixing of leak resources which potentially can reduce system performance and security (Dmytro Shkvyra via abaranchuk)
Date Fri, 19 Jun 2015 13:32:34 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk a59c66c67 -> 8a2cb5b35


http://git-wip-us.apache.org/repos/asf/ambari/blob/8a2cb5b3/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/customization/AmbariBanner.java
----------------------------------------------------------------------
diff --git a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/customization/AmbariBanner.java
b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/customization/AmbariBanner.java
index 850687e..ea0e39d 100644
--- a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/customization/AmbariBanner.java
+++ b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/customization/AmbariBanner.java
@@ -18,6 +18,9 @@
 package org.apache.ambari.shell.customization;
 
 import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import org.apache.commons.io.IOUtils;
 import org.springframework.shell.plugin.BannerProvider;
@@ -36,11 +39,22 @@ public class AmbariBanner implements BannerProvider {
 
   @Override
   public String getBanner() {
+    String res = null;
+    InputStream is = null;
     try {
-      return IOUtils.toString(getClass().getResourceAsStream("/banner.txt"));
+      is = getClass().getResourceAsStream("/banner.txt");
+      res = IOUtils.toString(is);
     } catch (IOException e) {
-      return "AmbariShell";
+      res = "AmbariShell";
+    } finally {
+      if (is != null) {
+        try {
+          is.close();
+        } catch (IOException ex) {
+        }
+      }
     }
+    return res;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/8a2cb5b3/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/flash/InstallProgress.java
----------------------------------------------------------------------
diff --git a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/flash/InstallProgress.java
b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/flash/InstallProgress.java
index dbf8e65..bad5b30 100644
--- a/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/flash/InstallProgress.java
+++ b/ambari-shell/ambari-groovy-shell/src/main/java/org/apache/ambari/shell/flash/InstallProgress.java
@@ -51,8 +51,8 @@ public class InstallProgress extends AbstractFlash {
         int intValue = decimal.intValue();
         if (intValue != SUCCESS && intValue != FAILED) {
           sb.append("Installation: ").append(decimal).append("% ");
-          int rounded = round(progress.setScale(0, BigDecimal.ROUND_UP).intValue() / 10);
-          for (int i = 0; i < 10; i++) {
+          long rounded = round(progress.setScale(0, BigDecimal.ROUND_UP).floatValue() / 10);
+          for (long i = 0; i < 10; i++) {
             if (i < rounded) {
               sb.append("=");
             } else {
@@ -71,7 +71,7 @@ public class InstallProgress extends AbstractFlash {
       }
     } else {
       if (exit) {
-        System.exit(0);
+        done = true;
       }
     }
     return sb.toString();


Mime
View raw message