Repository: metron
Updated Branches:
  refs/heads/master 5a6370a63 -> 73dc16e7a


METRON-711 StellarShell assigns variables even if an exception was thrown in 
the statement. (ottobackwards) closes apache/metron#686


Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/73dc16e7
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/73dc16e7
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/73dc16e7

Branch: refs/heads/master
Commit: 73dc16e7a40edb38de6657074c22860647441148
Parents: 5a6370a
Author: ottobackwards <ottobackwa...@gmail.com>
Authored: Thu Aug 17 01:17:44 2017 -0400
Committer: otto <o...@apache.org>
Committed: Thu Aug 17 01:17:44 2017 -0400

----------------------------------------------------------------------
 .../stellar/common/shell/StellarShell.java      | 40 ++++++++------------
 1 file changed, 15 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metron/blob/73dc16e7/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShell.java
----------------------------------------------------------------------
diff --git 
a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShell.java
 
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShell.java
index b8b31a3..0d2f0c3 100644
--- 
a/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShell.java
+++ 
b/metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/common/shell/StellarShell.java
@@ -264,12 +264,21 @@ public class StellarShell extends AeshConsoleCallback 
implements Completion {
         stellarExpression = stellarExpression.trim();
       }
     }
-    Object result = executeStellar(stellarExpression);
-    if(result != null && variable == null) {
-      writeLine(result.toString());
-    }
-    if(variable != null) {
-      executor.assign(variable, stellarExpression, result);
+
+    try {
+      Object result = executor.execute(stellarExpression);
+      if (result != null && variable == null) {
+        writeLine(result.toString());
+      }
+      if (variable != null) {
+        executor.assign(variable, stellarExpression, result);
+      }
+    } catch (Throwable t) {
+      if(variable != null) {
+        writeLine(String.format("%s ERROR: Variable %s not assigned", 
ERROR_PROMPT, variable));
+      }
+      writeLine(ERROR_PROMPT + t.getMessage());
+      t.printStackTrace();
     }
   }
 
@@ -352,25 +361,6 @@ public class StellarShell extends AeshConsoleCallback 
implements Completion {
     return StringUtils.startsWith(expression, DOC_PREFIX);
   }
 
-  /**
-   * Executes a Stellar expression.
-   * @param expression The expression to execute.
-   * @return The result of the expression.
-   */
-  private Object executeStellar(String expression) {
-    Object result = null;
-
-    try {
-      result = executor.execute(expression);
-
-    } catch(Throwable t) {
-      writeLine(ERROR_PROMPT + t.getMessage());
-      t.printStackTrace();
-    }
-
-    return result;
-  }
-
   private void write(String out) {
     System.out.print(out);
   }

Reply via email to