More cleanup - flushing output stream. Still can't seem to get the Scala console output. Need to figure that out.

This commit is contained in:
Sriram Krishnan 2015-12-17 16:20:02 -08:00
parent e13576fcfe
commit b19fda41b5
2 changed files with 11 additions and 4 deletions

View file

@ -36,6 +36,7 @@
<properties>
<scala.version>2.10.5</scala.version>
<hadoop.version>2.5.0</hadoop.version>
<scalding.version>0.15.1-RC13</scalding.version>
</properties>
<repositories>
@ -79,13 +80,13 @@
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scalding-core_2.10</artifactId>
<version>0.15.1-RC13</version>
<version>${scalding.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scalding-repl_2.10</artifactId>
<version>0.15.1-RC13</version>
<version>${scalding.version}</version>
</dependency>
<dependency>

View file

@ -150,7 +150,9 @@ public class ScaldingInterpreter extends Interpreter {
}
@Override
public void close() {}
public void close() {
interpreter.intp().close();
}
@Override
@ -180,7 +182,9 @@ public class ScaldingInterpreter extends Interpreter {
}
linesToRun[lines.length] = "print(\"\")";
Console.setOut(new PrintStream(out));
PrintStream ps = new PrintStream(out);
Console.setOut(ps);
Console.setErr(ps);
out.reset();
Code r = null;
String incomplete = "";
@ -208,6 +212,7 @@ public class ScaldingInterpreter extends Interpreter {
r = getResultCode(res);
if (r == Code.ERROR) {
ps.flush();
return new InterpreterResult(r, out.toString());
} else if (r == Code.INCOMPLETE) {
incomplete += s + "\n";
@ -219,6 +224,7 @@ public class ScaldingInterpreter extends Interpreter {
if (r == Code.INCOMPLETE) {
return new InterpreterResult(r, "Incomplete expression");
} else {
ps.flush();
return new InterpreterResult(r, out.toString());
}
}