You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2016/12/12 14:48:07 UTC

[2/2] ambari git commit: AMBARI-19153. "Create Principals" fails intermittently (dlysnichenko)

AMBARI-19153. "Create Principals" fails intermittently (dlysnichenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9ccd9979
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ccd9979
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ccd9979

Branch: refs/heads/trunk
Commit: 9ccd9979c72812d58e220158c2869a053883b392
Parents: c6f90cf
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Dec 12 16:46:49 2016 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Dec 12 16:47:36 2016 +0200

----------------------------------------------------------------------
 .../ambari/server/utils/ShellCommandUtil.java   | 28 +++++++++++---------
 1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9ccd9979/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
index 3152a0c..95a4b27 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
@@ -436,23 +436,27 @@ public class ShellCommandUtil {
 
       interactiveHandler.start();
 
-      while (!interactiveHandler.done()) {
-        StringBuilder query = new StringBuilder();
+      try {
+        while (!interactiveHandler.done()) {
+          StringBuilder query = new StringBuilder();
 
-        while (reader.ready()) {
-          query.append((char) reader.read());
-        }
+          while (reader.ready()) {
+            query.append((char) reader.read());
+          }
 
-        String response = interactiveHandler.getResponse(query.toString());
+          String response = interactiveHandler.getResponse(query.toString());
 
-        if (response != null) {
-          writer.write(response);
-          writer.newLine();
-          writer.flush();
+            if (response != null) {
+              writer.write(response);
+              writer.newLine();
+              writer.flush();
+            }
         }
+      } catch (IOException ex){
+        // ignore exception as command possibly can be finished before writer.flush() or writer.write() called
+      } finally {
+        writer.close();
       }
-
-      writer.close();
     }
 
     //TODO: not sure whether output buffering will work properly