Ivan Sopov created AVRO-2135:
--------------------------------
Summary: ResolvingGrammarGenerator.LitS2 equals method violates
contract
Key: AVRO-2135
URL: https://issues.apache.org/jira/browse/AVRO-2135
Project: Avro
Issue Type: Bug
Components: java
Affects Versions: 1.8.2
Reporter: Ivan Sopov
In comments this class is called "Clever trick", however its equals method does
violates the equals contract, as demonstrated by this small program:
{code:java}
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));
}
}{code}
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.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)