Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DAFFODIL-2768

SAX unparse can lead to a hanging thread if the XMLReader stops sending events

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.4.0
    • 4.0.0
    • Back End, Unparsing
    • None

    Description

      When unparsing with the SAX API (using the DaffodilUnparseContentHandler), we spawn an unparse thread to mimic the behavior of coroutines. If the ContentHandler detects an issue in the incoming events (e.g. mixed content) or the unparse thread/coroutine is notified and finishes, then the thread shuts down as expected.

      However, if the ContentHandler throws an unexpected exception during processing (which would be a bug) or the XMLReader throws an exception (e.g. invalid XML), then the unparse coroutine/thread is never notified and is stuck waiting for more events that will never come. And nothing in the SAX API notifies the DaffodilUnparseContentHandler so that it can cause the thread to stop. It seems the SAX API assumes all ContentHandlers are stateless and will just be garbaged collected, but that isn't the case with our DaffodilUnparseContentHandler.

      One potential solution is to add a reset/cleanup method to the DaffodilUnparseContentHandler, and very clearly document that if this isn't called after an XMLReader is exits, then it is possible that the thread will hang and never be shutdown.

      Attachments

        Activity

          People

            slawrence Steve Lawrence
            slawrence Steve Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: