You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mi...@apache.org on 2016/09/02 09:44:52 UTC

zeppelin git commit: ZEPPELIN-1374. Should prevent use dot in interpreter name

Repository: zeppelin
Updated Branches:
  refs/heads/master b89e35e01 -> 33ddc00c6


ZEPPELIN-1374. Should prevent use dot in interpreter name

### What is this PR for?
dot is invalid for interpreter name as it is used as the separator of interpreter group name and interpreter name.

### What type of PR is it?
[Improvement]

### Todos
* [ ] - Task

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-1374

### How should this be tested?
Tested it manually as shown in the screenshot.

### Screenshots (if appropriate)
![image](https://cloud.githubusercontent.com/assets/164491/17995181/3047152e-6b92-11e6-9fbf-c683330359a9.png)

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

Author: Jeff Zhang <zj...@apache.org>

Closes #1365 from zjffdu/ZEPPELIN-1374 and squashes the following commits:

d36d437 [Jeff Zhang] add rest api checking
0620c6a [Jeff Zhang] ZEPPELIN-1374. Should prevent use dot in interpreter name


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

Branch: refs/heads/master
Commit: 33ddc00c637d043a31f3a7f2e861f58f2c1ebc5a
Parents: b89e35e
Author: Jeff Zhang <zj...@apache.org>
Authored: Mon Aug 29 10:35:06 2016 +0800
Committer: Mina Lee <mi...@apache.org>
Committed: Fri Sep 2 11:44:12 2016 +0200

----------------------------------------------------------------------
 .../src/app/interpreter/interpreter.controller.js         |  9 +++++++++
 .../apache/zeppelin/interpreter/InterpreterFactory.java   |  3 +++
 .../zeppelin/interpreter/InterpreterFactoryTest.java      | 10 ++++++++++
 3 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/33ddc00c/zeppelin-web/src/app/interpreter/interpreter.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/interpreter/interpreter.controller.js b/zeppelin-web/src/app/interpreter/interpreter.controller.js
index 4be35ef..60cb0f7 100644
--- a/zeppelin-web/src/app/interpreter/interpreter.controller.js
+++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js
@@ -325,6 +325,15 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl',
         return;
       }
 
+      if (!$scope.newInterpreterSetting.name.indexOf('.') >= 0) {
+        BootstrapDialog.alert({
+          closable: true,
+          title: 'Add interpreter',
+          message: '\'.\' is invalid for interpreter name'
+        });
+        return;
+      }
+
       if (_.findIndex($scope.interpreterSettings, {'name': $scope.newInterpreterSetting.name}) >= 0) {
         BootstrapDialog.alert({
           closable: true,

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/33ddc00c/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
index 30411d1..30b0153 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/InterpreterFactory.java
@@ -506,6 +506,9 @@ public class InterpreterFactory implements InterpreterGroupFactory {
 
   public InterpreterSetting createNewSetting(String name, String group,
       List<Dependency> dependencies, InterpreterOption option, Properties p) throws IOException {
+    if (name.indexOf(".") >= 0) {
+      throw new IOException("'.' is invalid for InterpreterSetting name.");
+    }
     InterpreterSetting setting = createFromInterpreterSettingRef(group);
     setting.setName(name);
     setting.setGroup(group);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/33ddc00c/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
----------------------------------------------------------------------
diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
index c344082..5e44d62 100644
--- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
+++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterFactoryTest.java
@@ -157,4 +157,14 @@ public class InterpreterFactoryTest {
     assertEquals("className1", factory.getInterpreter("note", "test-group1").getClassName());
     assertEquals("className1", factory.getInterpreter("note", "group1").getClassName());
   }
+
+  @Test
+  public void testInvalidInterpreterSettingName() {
+    try {
+      factory.createNewSetting("new.mock1", "mock1", new LinkedList<Dependency>(), new InterpreterOption(false), new Properties());
+      fail("expect fail because of invalid InterpreterSetting Name");
+    } catch (IOException e) {
+      assertEquals("'.' is invalid for InterpreterSetting name.", e.getMessage());
+    }
+  }
 }