You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2016/05/24 05:17:16 UTC

incubator-zeppelin git commit: [ZEPPELIN-577] ASCII control character errors in Zeppelin

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 89166f0fd -> 61f0a5c24


[ZEPPELIN-577] ASCII control character errors in Zeppelin

### What is this PR for?
Take care of `interpreter not found` issue when code is copied from CRLF line ending editor

### What type of PR is it?
Bug Fix

### What is the Jira issue?
[ZEPPELIN-577](https://issues.apache.org/jira/browse/ZEPPELIN-577)

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

Author: Mina Lee <mi...@nflabs.com>

Closes #894 from minahlee/ZEPPELIN-577 and squashes the following commits:

3354a6e [Mina Lee] [ZEPPELIN-577] take care of all whitespace followed by interpreter repl name
b930af2 [Mina Lee] [ZEPPELIN-577] ASCII control character errors in Zeppelin


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

Branch: refs/heads/master
Commit: 61f0a5c24009234673a8e6f6995c4bb08d883705
Parents: 89166f0
Author: Mina Lee <mi...@nflabs.com>
Authored: Wed May 18 14:26:37 2016 +0900
Committer: Lee moon soo <mo...@apache.org>
Committed: Mon May 23 22:18:15 2016 -0700

----------------------------------------------------------------------
 .../org/apache/zeppelin/notebook/Paragraph.java |  2 +-
 .../apache/zeppelin/notebook/ParagraphTest.java | 22 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/61f0a5c2/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index 6f2592b..9a50a1a 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -143,7 +143,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
     int scriptHeadIndex = 0;
     for (int i = 0; i < text.length(); i++) {
       char ch = text.charAt(i);
-      if (ch == ' ' || ch == '\n' || ch == '(') {
+      if (Character.isWhitespace(ch) || ch == '(') {
         scriptHeadIndex = i;
         break;
       }

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/61f0a5c2/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
index a594873..e08fdf8 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/notebook/ParagraphTest.java
@@ -41,6 +41,7 @@ public class ParagraphTest {
     text = "%table 1234567";
     assertEquals("1234567", Paragraph.getScriptBody(text));
   }
+
   @Test
   public void scriptBodyWithoutReplName() {
     String text = "12345678";
@@ -48,6 +49,27 @@ public class ParagraphTest {
   }
 
   @Test
+  public void replNameEndsWithWhitespace() {
+    String text = "%md\r\n###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+
+    text = "%md\t###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+
+    text = "%md\u000b###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+
+    text = "%md\f###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+
+    text = "%md\n###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+
+    text = "%md ###Hello";
+    assertEquals("md", Paragraph.getRequiredReplName(text));
+  }
+
+  @Test
   public void should_extract_variable_from_angular_object_registry() throws Exception {
     //Given
     final String noteId = "noteId";