Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1781

Schema.parse is not thread safe

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.8.0
    • Fix Version/s: 1.8.0
    • Component/s: java
    • Labels:
      None

      Description

      Post AVRO-1497, Schema.parse calls LogicalTypes.fromSchemaIgnoreInvalid on any schema that is expressed as a JSON object (anything except bare primitives).

      That static method relies on a static cache based on WeakIdentityHashMap (WIHM).

      WIHM clearly states that it isn't threadsafe ref

       * 
       * Note that this implementation is not synchronized.
       * </b>
       */
      public class WeakIdentityHashMap<K, V> implements Map<K, V> {
      

      All of the Schema.Parser instances use that same static Schema.parse method.

      The end result is that as-is it's only safe to have a single thread parsing schemas in a given JVM.

        Attachments

        1. AVRO-1781.1.patch
          33 kB
          Ryan Blue
        2. AVRO-1781.2.patch
          35 kB
          Ryan Blue
        3. AVRO-1781-ADDENDUM.1.patch
          2 kB
          Ryan Blue
        4. AVRO-1781-ADDENDUM.2.patch
          2 kB
          Ryan Blue

        Issue Links

          Activity

            People

            • Assignee:
              rdblue Ryan Blue
              Reporter:
              busbey Sean Busbey

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment