Repl: fix a problem where handling an incomplete message led to xml parsing exception
This commit is contained in:
@@ -44,6 +44,7 @@ class ReplOutputHandler(
|
||||
private var isBuildInfoChecked = false
|
||||
private val dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
|
||||
private val outputProcessor = ReplOutputProcessor(runner)
|
||||
private val inputBuffer = StringBuilder()
|
||||
|
||||
override fun isSilentlyDestroyOnClose() = true
|
||||
|
||||
@@ -52,8 +53,17 @@ class ReplOutputHandler(
|
||||
if (text.startsWith("warning: classpath entry points to a non-existent location")) return
|
||||
|
||||
// skip "/usr/lib/jvm/java-8-oracle/bin/java -cp ..." intro
|
||||
if (!text.startsWith(XML_PREFIX)) return super.notifyTextAvailable(text, key)
|
||||
if (!text.startsWith(XML_PREFIX) && inputBuffer.length == 0) return super.notifyTextAvailable(text, key)
|
||||
|
||||
inputBuffer.append(text)
|
||||
val resultingText = inputBuffer.toString()
|
||||
if (resultingText.endsWith("\n")) {
|
||||
handleReplMessage(resultingText)
|
||||
inputBuffer.setLength(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleReplMessage(text: String) {
|
||||
val output = dBuilder.parse(strToSource(text))
|
||||
val root = output.firstChild as Element
|
||||
val outputType = root.getAttribute("type")
|
||||
|
||||
Reference in New Issue
Block a user