Skip to content

Commit dbdaf84

Browse files
bbonninFelix Cheung
authored andcommitted
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 <[email protected]> Closes apache#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
1 parent e246aa9 commit dbdaf84

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

elasticsearch/src/main/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public void close() {
141141
@Override
142142
public InterpreterResult interpret(String cmd, InterpreterContext interpreterContext) {
143143
logger.info("Run Elasticsearch command '" + cmd + "'");
144+
145+
if (StringUtils.isEmpty(cmd) || StringUtils.isEmpty(cmd.trim())) {
146+
return new InterpreterResult(InterpreterResult.Code.SUCCESS);
147+
}
144148

145149
int currentResultSize = resultSize;
146150

elasticsearch/src/test/java/org/apache/zeppelin/elasticsearch/ElasticsearchInterpreterTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,14 @@ public void testDelete() {
198198
assertEquals("11", res.message());
199199
}
200200

201+
@Test
202+
public void testMisc() {
203+
204+
InterpreterResult res = interpreter.interpret(null, null);
205+
assertEquals(Code.SUCCESS, res.code());
206+
207+
res = interpreter.interpret(" \n \n ", null);
208+
assertEquals(Code.SUCCESS, res.code());
209+
}
210+
201211
}

0 commit comments

Comments
 (0)