Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.8.2
-
None
-
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.