Skip to content

Commit

Permalink
fix CPGQLServerTests: only read a line if there is something to read
Browse files Browse the repository at this point in the history
before this, the Thread would stall at `reader.readLine` forever
  • Loading branch information
mpollmeier committed Apr 2, 2021
1 parent 0be57f7 commit 1c2caa2
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class UserRunnable(queue: BlockingQueue[Job], writer: PrintWriter, reader: Buffe
terminate = true
} else {
sendQueryToAmmonite(job)
val stdoutPair = stdOutUpToMarker()
val stdOutput = stdoutPair.get
val errOutput = exhaustStderr()
val result = new QueryResult(stdOutput, errOutput, job.uuid)
job.observer(result)
stdOutUpToMarker().map { stdOutput =>
val errOutput = exhaustStderr()
val result = new QueryResult(stdOutput, errOutput, job.uuid)
job.observer(result)
}
}
}
} catch {
Expand All @@ -51,7 +51,10 @@ class UserRunnable(queue: BlockingQueue[Job], writer: PrintWriter, reader: Buffe

private def stdOutUpToMarker(): Option[String] = {
var currentOutput: String = ""
var line = reader.readLine()
var line =
if (reader.ready) reader.readLine()
else null

while (line != null) {
if (!line.startsWith(magicEchoSeq) && !line.isEmpty) {
val uuid = uuidFromLine(line)
Expand Down

0 comments on commit 1c2caa2

Please sign in to comment.