Skip to content

Commit

Permalink
LIVY-269. Fixed SparkRInterpreter hangs forever on executing x[. (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-the-man authored Dec 21, 2016
1 parent f6829a5 commit 4eec41b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class SparkRInterpreter(process: Process,
}

private def sendRequest(code: String): String = {
stdin.println(code)
stdin.println(s"""try(eval(parse(text="$code")))""")
stdin.flush()

stdin.println(PRINT_MARKER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,18 @@ class SparkRInterpreterSpec extends BaseInterpreterSpec {
it should "report an error if accessing an unknown variable" in withInterpreter { interpreter =>
val response = interpreter.execute("x")
response should equal(Interpreter.ExecuteSuccess(
TEXT_PLAIN -> "Error: object 'x' not found"
TEXT_PLAIN -> "Error in eval(expr, envir, enclos) : object 'x' not found"
))
}


it should "not hang when executing incomplete statements" in withInterpreter { interpreter =>
val response = interpreter.execute("x[")
response should equal(Interpreter.ExecuteSuccess(
TEXT_PLAIN ->
"""Error in parse(text = "x[") : <text>:2:0: unexpected end of input
|1: x[
| ^""".stripMargin
))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SparkRSessionSpec extends BaseSessionSpec {
"status" -> "ok",
"execution_count" -> 0,
"data" -> Map(
"text/plain" -> "Error: object 'x' not found"
"text/plain" -> "Error in eval(expr, envir, enclos) : object 'x' not found"
)
))

Expand Down

0 comments on commit 4eec41b

Please sign in to comment.