Skip to content

Commit 2300ebc

Browse files
committed
Update to latest change in interpeter constructs
1 parent ecf8bc4 commit 2300ebc

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

spark/src/main/java/org/apache/zeppelin/spark/SparkRInterpreter.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,22 @@ public List<String> completion(String buf, int cursor) {
157157
}
158158

159159
private SparkInterpreter getSparkInterpreter() {
160-
for (Interpreter intp : getInterpreterGroup()) {
161-
if (intp.getClassName().equals(SparkInterpreter.class.getName())) {
162-
Interpreter p = intp;
163-
while (p instanceof WrappedInterpreter) {
164-
if (p instanceof LazyOpenInterpreter) {
165-
p.open();
166-
}
167-
p = ((WrappedInterpreter) p).getInnerInterpreter();
168-
}
169-
return (SparkInterpreter) p;
160+
LazyOpenInterpreter lazy = null;
161+
SparkInterpreter spark = null;
162+
Interpreter p = getInterpreterInTheSameSessionByClassName(SparkInterpreter.class.getName());
163+
164+
while (p instanceof WrappedInterpreter) {
165+
if (p instanceof LazyOpenInterpreter) {
166+
lazy = (LazyOpenInterpreter) p;
170167
}
168+
p = ((WrappedInterpreter) p).getInnerInterpreter();
169+
}
170+
spark = (SparkInterpreter) p;
171+
172+
if (lazy != null) {
173+
lazy.open();
171174
}
172-
return null;
175+
return spark;
173176
}
174177

175178
protected static ZeppelinRFactory zeppelinR() {

spark/src/test/java/org/apache/zeppelin/spark/SparkRInterpreterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.junit.*;
3232
import org.junit.runner.RunWith;
3333
import org.mockito.Mockito;
34+
import org.powermock.core.classloader.annotations.PowerMockIgnore;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
3637

@@ -43,6 +44,7 @@
4344

4445
@RunWith(PowerMockRunner.class)
4546
@PrepareForTest(SparkRInterpreter.ZeppelinRFactory.class)
47+
@PowerMockIgnore({"org.apache.spark.*", "org.apache.hadoop.*", "akka.*", "org.w3c.*", "javax.xml.*", "org.xml.*", "scala.*", "org.apache.cxf.*"})
4648
public class SparkRInterpreterTest {
4749
private static final Logger LOGGER = LoggerFactory.getLogger(SparkRInterpreterTest.class);
4850

@@ -74,7 +76,6 @@ private static void initInterpreters() {
7476

7577
sparkInterpreter = new SparkInterpreter(p);
7678
intpGroup = new InterpreterGroup();
77-
intpGroup.add(sparkInterpreter);
7879

7980
zeppelinRFactory = mock(SparkRInterpreter.ZeppelinRFactory.class);
8081
doNothing().when(zeppelinRFactory).open(Mockito.anyString(), Mockito.anyString(), any(SparkInterpreter.class));
@@ -83,7 +84,6 @@ private static void initInterpreters() {
8384
mockStatic(SparkRInterpreter.ZeppelinRFactory.class);
8485
when(SparkRInterpreter.ZeppelinRFactory.instance()).thenReturn(zeppelinRFactory);
8586

86-
intpGroup.add(sparkRInterpreter);
8787
sparkRInterpreter = new SparkRInterpreter(p);
8888
sparkRInterpreter.setInterpreterGroup(intpGroup);
8989
sparkRInterpreter.open();

0 commit comments

Comments
 (0)