Skip to content

Threading in XMLEventReader swallows IO/Parse exceptions. #4267

@scabug

Description

@scabug

=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===

class XMLConverter(val input : InputStream) {

  def consume = {
    try {
      val reader = new XMLEventReader(Source.Source.fromInputStream(input,"utf-8"))
      (new Map() /: reader)( (map,event) => { // some logic here })
    } catch {
      case e : Throwable => log (e)
    }
  }

}

With that code, if the input streams throws any IOException, or even if it is a malformed stream and causes a ParseException, will result on thread block indefinitely. That's due XMLEventReader runs on its own thread but it does not exception handling.

=== What is the expected behavior? ===
On error, pass it to consuming threads:

  • By passing some error event ~ EvError(e:Throwable)
  • By throwing the error directly on the iterator thread

I've made a modification on the XMLEventReader source file to avoid this behavior and throw the exception to any iterating thread.

=== What versions of the following are you using? ===

  • Scala: 2.8.1.final
  • Java: 1.6.0_22
  • Operating system: Mac OS X 10.6.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions