Avro
  1. Avro
  2. AVRO-1055

Race condition in Java fingerprinting code

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.0
    • Fix Version/s: 1.6.3
    • Component/s: java
    • Labels:
      None

      Description

      There is a subtle race condition. If the fpTable64 is not yet initialized and two thread try to compute FP for two schemas (or the same schema) at the same time, one thread will start initializing the table while the other can start using the partially initialized table giving wrong result.

      The forthcoming patch fixes that issue

      1. AVRO-1055.patch
        1 kB
        Thiruvalluvan M. G.

        Activity

        Hide
        Thiruvalluvan M. G. added a comment -

        This patch solves the problem by making the FP table a static array and initializing it in a static block. Java ensures that nobody is able to access the table until it is fully initialized.

        By making it a static member of an inner static class rather than SchemaNormalization class itself, we ensure that the Table is initialized only when it is required. (the class loader will load the inner class only when the table is accessed for the first time)

        Show
        Thiruvalluvan M. G. added a comment - This patch solves the problem by making the FP table a static array and initializing it in a static block. Java ensures that nobody is able to access the table until it is fully initialized. By making it a static member of an inner static class rather than SchemaNormalization class itself, we ensure that the Table is initialized only when it is required. (the class loader will load the inner class only when the table is accessed for the first time)
        Hide
        Doug Cutting added a comment -

        +1 Looks good to me. You might add a comment saying something like, "Nested class used so that table is not built unless it's used."

        Show
        Doug Cutting added a comment - +1 Looks good to me. You might add a comment saying something like, "Nested class used so that table is not built unless it's used."
        Hide
        Thiruvalluvan M. G. added a comment -

        Included the comment as suggested by Doug.
        Committed revision 1325207. Thank you Doug for reviewing.

        Show
        Thiruvalluvan M. G. added a comment - Included the comment as suggested by Doug. Committed revision 1325207. Thank you Doug for reviewing.

          People

          • Assignee:
            Thiruvalluvan M. G.
            Reporter:
            Thiruvalluvan M. G.
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development