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

ResolvingGrammarGenerator.LitS2 equals method violates contract

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.8.2
    • None
    • java
    • None

    Description

      In comments this class is called "Clever trick", however its equals method does violates the equals contract, as demonstrated by this small program:

      package org.apache.avro.io.parsing;
      
      import org.apache.avro.Schema;
      import org.apache.avro.Schema.Type;
      import org.apache.avro.io.parsing.ResolvingGrammarGenerator.LitS2;
      import org.apache.avro.io.parsing.ValidatingGrammarGenerator.LitS;
      
      public class LitSTest {
          public static void main(String[] args) {
              Schema schema = Schema.create(Type.BOOLEAN);
              LitS parent = new ValidatingGrammarGenerator.LitS(schema);
              LitS2 child = new ResolvingGrammarGenerator.LitS2(schema,schema);
      
              System.out.println(parent.equals(child));
              System.out.println(child.equals(parent));
          }
      }

      Behavior is dependent on internal non-standardized behavior of the HashMap and may broke with update or switch to other java vendor.

      Moreover, without LitS2 there is no sense in LitS class if IdentityHashMap is used.

      Attachments

        Activity

          People

            Unassigned Unassigned
            isopov Ivan Sopov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: