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

Schema.parse is not thread safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.8.0
    • 1.8.0
    • java
    • 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

              rdblue Ryan Blue
              busbey Sean Busbey
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: