mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Ignore preceding newline from scala RepleReporter.error
This commit is contained in:
parent
5bb38c89ae
commit
6908bdf14d
2 changed files with 22 additions and 10 deletions
|
|
@ -993,6 +993,7 @@ public class SparkInterpreter extends Interpreter {
|
|||
}
|
||||
|
||||
private Results.Result interpret(String line) {
|
||||
out.ignoreLeadingNewLinesFromScalaReporter();
|
||||
return (Results.Result) Utils.invokeMethod(
|
||||
intp,
|
||||
"interpret",
|
||||
|
|
@ -1261,7 +1262,6 @@ public class SparkInterpreter extends Interpreter {
|
|||
if (varName == null || varName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object lastObj = null;
|
||||
try {
|
||||
if (Utils.isScala2_10()) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import java.io.IOException;
|
|||
public class InterpreterOutputStream extends LogOutputStream {
|
||||
public static Logger logger;
|
||||
InterpreterOutput interpreterOutput;
|
||||
boolean ignoreLeadingNewLinesFromScalaReporter = false;
|
||||
|
||||
public InterpreterOutputStream(Logger logger) {
|
||||
this.logger = logger;
|
||||
|
|
@ -45,6 +46,18 @@ public class InterpreterOutputStream extends LogOutputStream {
|
|||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if (ignoreLeadingNewLinesFromScalaReporter && b == '\n') {
|
||||
StackTraceElement[] stacks = Thread.currentThread().getStackTrace();
|
||||
for (StackTraceElement stack : stacks) {
|
||||
if (stack.getClassName().equals("scala.tools.nsc.interpreter.ReplReporter") &&
|
||||
stack.getMethodName().equals("error")) {
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ignoreLeadingNewLinesFromScalaReporter = false;
|
||||
}
|
||||
super.write(b);
|
||||
if (interpreterOutput != null) {
|
||||
interpreterOutput.write(b);
|
||||
|
|
@ -53,17 +66,13 @@ public class InterpreterOutputStream extends LogOutputStream {
|
|||
|
||||
@Override
|
||||
public void write(byte [] b) throws IOException {
|
||||
super.write(b);
|
||||
if (interpreterOutput != null) {
|
||||
interpreterOutput.write(b);
|
||||
}
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte [] b, int offset, int len) throws IOException {
|
||||
super.write(b, offset, len);
|
||||
if (interpreterOutput != null) {
|
||||
interpreterOutput.write(b, offset, len);
|
||||
public void write(byte [] b, int off, int len) throws IOException {
|
||||
for (int i = off; i < len; i++) {
|
||||
write(b[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +89,6 @@ public class InterpreterOutputStream extends LogOutputStream {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
|
|
@ -88,4 +96,8 @@ public class InterpreterOutputStream extends LogOutputStream {
|
|||
interpreterOutput.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public void ignoreLeadingNewLinesFromScalaReporter() {
|
||||
ignoreLeadingNewLinesFromScalaReporter = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue