zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From felixche...@apache.org
Subject incubator-zeppelin git commit: ZEPPELIN-602 elasticsearch throws ArrayIndexOutOfBoundsException
Date Tue, 19 Jan 2016 06:24:30 GMT
Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master e246aa9f9 -> dbdaf84e4


ZEPPELIN-602 elasticsearch throws ArrayIndexOutOfBoundsException

### What is this PR for?
Fix for https://issues.apache.org/jira/browse/ZEPPELIN-602
"elasticsearch throws ArrayIndexOutOfBoundsException for interpreting an empty paragraph"

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

### Todos
* [X] - Code : check cmd parameter

### Is there a relevant Jira issue?
ZEPPELIN-602

### How should this be tested?
Start elasticsearch interpreter with an empty paragraph

### 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: Bruno Bonnin <bbonnin@gmail.com>

Closes #646 from bbonnin/master and squashes the following commits:

05993d0 [Bruno Bonnin] Update unit tests and complete fix
378bf52 [Bruno Bonnin] Update ElasticsearchInterpreter.java
7651647 [Bruno Bonnin] ZEPPELIN-602 elasticsearch throws ArrayIndexOutOfBoundsException for
interpreting an empty paragraph


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

Branch: refs/heads/master
Commit: dbdaf84e4bcf305e7a10b85d087d89f4c7e20423
Parents: e246aa9
Author: Bruno Bonnin <bbonnin@gmail.com>
Authored: Sat Jan 16 21:02:11 2016 +0100
Committer: Felix Cheung <felixcheung@apache.org>
Committed: Mon Jan 18 22:23:55 2016 -0800

----------------------------------------------------------------------
 .../zeppelin/elasticsearch/ElasticsearchInterpreter.java  |  4 ++++
 .../elasticsearch/ElasticsearchInterpreterTest.java       | 10 ++++++++++
 2 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/dbdaf84e/elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java
----------------------------------------------------------------------
diff --git a/elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java
b/elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java
index ac94abf..50cf739 100644
--- a/elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java
+++ b/elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java
@@ -141,6 +141,10 @@ public class ElasticsearchInterpreter extends Interpreter {
   @Override
   public InterpreterResult interpret(String cmd, InterpreterContext interpreterContext) {
     logger.info("Run Elasticsearch command '" + cmd + "'");
+ 
+    if (StringUtils.isEmpty(cmd) || StringUtils.isEmpty(cmd.trim())) {
+      return new InterpreterResult(InterpreterResult.Code.SUCCESS);
+    }
 
     int currentResultSize = resultSize;
 

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/dbdaf84e/elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java
----------------------------------------------------------------------
diff --git a/elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java
b/elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java
index 248258f..42f08ad 100644
--- a/elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java
+++ b/elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java
@@ -198,4 +198,14 @@ public class ElasticsearchInterpreterTest {
     assertEquals("11", res.message());
   }
 
+  @Test
+  public void testMisc() {
+
+    InterpreterResult res = interpreter.interpret(null, null);
+    assertEquals(Code.SUCCESS, res.code());
+
+    res = interpreter.interpret("   \n \n ", null);
+    assertEquals(Code.SUCCESS, res.code());
+  }
+
 }


Mime
View raw message