Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.6 6c9a89e67 -> 8f8b056da


ZEPPELIN-1225. Errors before the last shell command are ignored

What is this PR for?

The problem is that command "bash -c " will always return 0 as long as the last 
line of shell script run correctly. e.g the following command will run 
correctly without any error message.

hello
pwd
This PR will redirect stderr and stdout to the same place, and will display 
both the stderr and stdout to frontend just like what user see in the native 
shell terminal. So the output of above command will be as following

bash: hello: command not found
/Users/jzhang/github/zeppelin
What type of PR is it?

[Bug Fix]

What is the Jira issue?

https://issues.apache.org/jira/browse/ZEPPELIN-1225
How should this be tested?

Unit test is added and also manually verify it on zeppelin notebook.

Screenshots (if appropriate)

Questions:

Does the licenses files need update? No
Is there breaking changes for older versions? No
Does this needs documentation? No

Author: Jeff Zhang <zjf...@apache.org>

Closes #1245 from zjffdu/ZEPPELIN-1225-0.6 and squashes the following commits:

e1aa898 [Jeff Zhang] ZEPPELIN-1225. Errors before the last shell command are 
ignored


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/8f8b056d
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/8f8b056d
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/8f8b056d

Branch: refs/heads/branch-0.6
Commit: 8f8b056da70d37b14a75ae9aeef7917278db9266
Parents: 6c9a89e
Author: Jeff Zhang <zjf...@apache.org>
Authored: Fri Jul 29 18:56:24 2016 +0800
Committer: Lee moon soo <m...@apache.org>
Committed: Sun Jul 31 08:11:19 2016 +0900

----------------------------------------------------------------------
 .../org/apache/zeppelin/shell/ShellInterpreter.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/8f8b056d/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
----------------------------------------------------------------------
diff --git 
a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java 
b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
index 8f6f0d0..f00201c 100644
--- a/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
+++ b/shell/src/main/java/org/apache/zeppelin/shell/ShellInterpreter.java
@@ -79,8 +79,8 @@ public class ShellInterpreter extends Interpreter {
     }
     cmdLine.addArgument(cmd, false);
     DefaultExecutor executor = new DefaultExecutor();
-    ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
-    executor.setStreamHandler(new PumpStreamHandler(contextInterpreter.out, 
errorStream));
+    executor.setStreamHandler(new PumpStreamHandler(contextInterpreter.out,
+            contextInterpreter.out));
     executor.setWatchdog(new ExecuteWatchdog(commandTimeOut));
 
     Job runningJob = getRunningJob(contextInterpreter.getParagraphId());
@@ -95,7 +95,14 @@ public class ShellInterpreter extends Interpreter {
       int exitValue = e.getExitValue();
       logger.error("Can not run " + cmd, e);
       Code code = Code.ERROR;
-      String msg = errorStream.toString();
+      String msg = null;
+      try {
+        contextInterpreter.out.flush();
+        msg = new String(contextInterpreter.out.toByteArray());
+      } catch (IOException e1) {
+        logger.error(e1.getMessage());
+        msg = e1.getMessage();
+      }
       if (exitValue == 143) {
         code = Code.INCOMPLETE;
         msg = msg + "Paragraph received a SIGTERM.\n";

Reply via email to