Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-2746

ParsingReader#throwable is shared across threads but not volatile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.19
    • None
    • core
    • None

    Description

      The field throwable in org.apache.tika.parser.ParsingReader is modified by the background worker thread (in ParsingTask.run) and read by the reader thread (in ParsingReader.read). However, the field is not volatile, and no locks are used to protect its access, which means that there is no guarantee about if and when the update to throwable by the worker thread will be visible to the reader thread.

      This can technically lead to data races, stale reads, and a slew of other non-deterministic behavior if the content handler throws an exception while parsing.

       

      As a side note: the throwable field is marked as transient. I do not see why that is the case, given that the reader is not serializable. Is this just a typo from an intended volatile modifier?

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            rohanpadhye Rohan Padhye
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: