Steven Aerts created AVRO-4139:
----------------------------------

             Summary: [Java] Arrays containing maps cannot be checked for 
equals anymore
                 Key: AVRO-4139
                 URL: https://issues.apache.org/jira/browse/AVRO-4139
             Project: Apache Avro
          Issue Type: Bug
          Components: java
    Affects Versions: 1.12.0
         Environment: Reproduction scenario:
{code:java}
Schema schema = 
Schema.createArray(Schema.createMap(Schema.create(Schema.Type.STRING)));
GenericData.Array<Map<String, String>> a1 = new GenericData.Array<>(10, schema);
GenericData.Array<Map<String, String>> a2 = new GenericData.Array<>(10, schema);
a1.add(Map.of("a", "b"));
a2.add(Map.of("a", "b"));
assertEquals(a1, a2); {code}
            Reporter: Steven Aerts


Since the introduction of AbstractArray in avro 1.12, it is not possible 
anymore to compare arrays which contain an object which contains a map.

When you do so you get the following exception:
{code:java}
org.apache.avro.AvroRuntimeException: Can't compare maps!    at 
org.apache.avro.generic.GenericData.compare(GenericData.java:1309)
    at org.apache.avro.generic.GenericData.compare(GenericData.java:1301)
    at org.apache.avro.generic.GenericData.compare(GenericData.java:1202)
    at 
org.apache.avro.generic.GenericData$AbstractArray.equals(GenericData.java:358)
    at 
org.junit.jupiter.api.AssertionUtils.objectsAreEqual(AssertionUtils.java:110)
    at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:181)
    at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
    at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145) 
{code}
We have a PR which fixes this issue.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to