Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected RemoteInterpreterEventClient getEventClient() {

private void setSystemProperty(Properties properties) {
for (Object key : properties.keySet()) {
if (!RemoteInterpreter.isEnvString((String) key)) {
if (!RemoteInterpreterUtils.isEnvString((String) key)) {
String value = properties.getProperty((String) key);
if (value == null || value.isEmpty()) {
System.clearProperty((String) key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.zeppelin.interpreter.remote;

import org.apache.zeppelin.interpreter.InterpreterGroup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -73,4 +72,12 @@ public static String getInterpreterSettingId(String intpGrpId) {
}
return settingId;
}

public static boolean isEnvString(String key) {
if (key == null || key.length() == 0) {
return false;
}

return key.matches("^[A-Z_0-9]*");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.google.gson.Gson;
import org.apache.zeppelin.interpreter.InterpreterGroup;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess;
import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apache.thrift.TException;
import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterManagedProcess;
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess;
import org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService.Client;
import org.apache.zeppelin.scheduler.Job.Status;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.apache.zeppelin.interpreter;

import java.util.Properties;

/**
*
*/
public class DummyInterpreter extends Interpreter {

public DummyInterpreter(Properties property) {
super(property);
}

@Override
public void open() {

}

@Override
public void close() {

}

@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
return null;
}

@Override
public void cancel(InterpreterContext context) {

}

@Override
public FormType getFormType() {
return null;
}

@Override
public int getProgress(InterpreterContext context) {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import java.util.Properties;

import org.apache.zeppelin.interpreter.remote.mock.MockInterpreterA;
import org.apache.zeppelin.user.AuthenticationInfo;
import org.junit.Test;

Expand All @@ -31,7 +30,7 @@ public class InterpreterTest {
public void testDefaultProperty() {
Properties p = new Properties();
p.put("p1", "v1");
MockInterpreterA intp = new MockInterpreterA(p);
Interpreter intp = new DummyInterpreter(p);

assertEquals(1, intp.getProperty().size());
assertEquals("v1", intp.getProperty().get("p1"));
Expand All @@ -42,7 +41,7 @@ public void testDefaultProperty() {
public void testOverriddenProperty() {
Properties p = new Properties();
p.put("p1", "v1");
MockInterpreterA intp = new MockInterpreterA(p);
Interpreter intp = new DummyInterpreter(p);
Properties overriddenProperty = new Properties();
overriddenProperty.put("p1", "v2");
intp.setProperty(overriddenProperty);
Expand Down Expand Up @@ -74,7 +73,7 @@ public void testPropertyWithReplacedContextFields() {
Properties p = new Properties();
p.put("p1", "replName #{noteId}, #{paragraphTitle}, #{paragraphId}, #{paragraphText}, #{replName}, #{noteId}, #{user}," +
" #{authenticationInfo}");
MockInterpreterA intp = new MockInterpreterA(p);
Interpreter intp = new DummyInterpreter(p);
intp.setUserName(user);
String actual = intp.getProperty("p1");
InterpreterContext.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,13 @@ public RemoteInterpreter(Properties property, String sessionKey, String classNam
private Map<String, String> getEnvFromInterpreterProperty(Properties property) {
Map<String, String> env = new HashMap<>();
for (Object key : property.keySet()) {
if (isEnvString((String) key)) {
if (RemoteInterpreterUtils.isEnvString((String) key)) {
env.put((String) key, property.getProperty((String) key));
}
}
return env;
}

static boolean isEnvString(String key) {
if (key == null || key.length() == 0) {
return false;
}

return key.matches("^[A-Z_0-9]*");
}

@Override
public String getClassName() {
return className;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,13 +854,13 @@ public void should_push_local_angular_repo_to_remote() throws Exception {

@Test
public void testEnvStringPattern() {
assertFalse(RemoteInterpreter.isEnvString(null));
assertFalse(RemoteInterpreter.isEnvString(""));
assertFalse(RemoteInterpreter.isEnvString("abcDEF"));
assertFalse(RemoteInterpreter.isEnvString("ABC-DEF"));
assertTrue(RemoteInterpreter.isEnvString("ABCDEF"));
assertTrue(RemoteInterpreter.isEnvString("ABC_DEF"));
assertTrue(RemoteInterpreter.isEnvString("ABC_DEF123"));
assertFalse(RemoteInterpreterUtils.isEnvString(null));
assertFalse(RemoteInterpreterUtils.isEnvString(""));
assertFalse(RemoteInterpreterUtils.isEnvString("abcDEF"));
assertFalse(RemoteInterpreterUtils.isEnvString("ABC-DEF"));
assertTrue(RemoteInterpreterUtils.isEnvString("ABCDEF"));
assertTrue(RemoteInterpreterUtils.isEnvString("ABC_DEF"));
assertTrue(RemoteInterpreterUtils.isEnvString("ABC_DEF123"));
}

@Test
Expand Down