Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backport] SI-4339 Event errors and attribute fix
Improve attribute parsing and propagate errors across event thread. Otherwise tests just hang. This is tested, right? This is an upstream port of scala-xml 5f2cfadeb9e8574ed66f37dc7a7a868eb129a8a9
- Loading branch information
Showing
5 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Saw failure: scala.xml.parsing.FatalError: expected closing tag of foo | ||
EvElemStart(null,foo, bar="baz/>",) | ||
Saw failure: scala.xml.parsing.FatalError: expected closing tag of foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import scala.util.{ Try, Success, Failure } | ||
import xml._ | ||
import scala.io.Source.fromString | ||
import java.io.PrintStream | ||
|
||
object Test extends App { | ||
|
||
def quietSource(text: String) = new io.Source { | ||
override protected val iter = io.Source fromString text | ||
override def report(pos: Int, msg: String, out: PrintStream) = () | ||
} | ||
def reading(text: String)(f: pull.XMLEventReader => Unit): Unit = { | ||
val r = new pull.XMLEventReader(quietSource(text)) | ||
try f(r) | ||
finally r.stop() | ||
} | ||
def trying(body: => Unit): Unit = | ||
Try (body) match { | ||
case Success(_) => Console println "Expected failure" | ||
case Failure(e) => Console println s"Saw failure: $e" | ||
} | ||
|
||
val problematic = """<foo bar="baz/>""" | ||
|
||
trying ( | ||
parsing.ConstructingParser.fromSource(quietSource(problematic), false).document.docElem | ||
) | ||
|
||
trying ( | ||
reading(problematic) { r => | ||
while (r.hasNext) println(r.next()) | ||
} | ||
) | ||
} |