From fe660abb9663173998d6e02504ef3238f869c080 Mon Sep 17 00:00:00 2001 From: Andreas Weise Date: Sun, 18 Feb 2018 12:55:32 +0100 Subject: [PATCH] [ZEPPELIN-3243] fix IndexOutOfBoundsException when 'No interpreter is binded to this note' ### What is this PR for? I observed IndexOutOfBoundsException when using zeppelin locally on an existing notebook repository and with fresh interpreter.json file. The default Zeppelin behavior when using existing notebooks is the manual binding of the interpreter settings, which works fine. This PR simply avoids the IndexOutOfBoundsException. ### What type of PR is it? Bug Fix ### Todos - ### What is the Jira issue? [https://issues.apache.org/jira/browse/ZEPPELIN-3243](https://issues.apache.org/jira/browse/ZEPPELIN-3243) ### How should this be tested? - manual ### 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: Andreas Weise Closes #2808 from weand/ZEPPELIN-3243 and squashes the following commits: b97a38e [Andreas Weise] ZEPPELIN-3243 fix IndexOutOfBoundsException when 'No interpreter is binded to this note' --- .../zeppelin/interpreter/InterpreterSettingManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java index 711812e07f4..c3ec81bbb44 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterSettingManager.java @@ -412,7 +412,8 @@ private void registerInterpreterSetting(List registeredIn @VisibleForTesting public InterpreterSetting getDefaultInterpreterSetting(String noteId) { - return getInterpreterSettings(noteId).get(0); + List allInterpreterSettings = getInterpreterSettings(noteId); + return allInterpreterSettings.size() > 0 ? allInterpreterSettings.get(0) : null; } public List getInterpreterSettings(String noteId) { @@ -468,7 +469,7 @@ public Map getEditorSetting(Interpreter interpreter, String user group = replNameSplit[0]; } // when replName is 'name' of interpreter - if (defaultSettingName.equals(intpSetting.getName())) { + if (intpSetting.getName().equals(defaultSettingName)) { editor = intpSetting.getEditorFromSettingByClassName(interpreter.getClassName()); } // when replName is 'alias name' of interpreter or 'group' of interpreter