[
https://issues.apache.org/jira/browse/AVRO-4139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17969558#comment-17969558
]
ASF subversion and git services commented on AVRO-4139:
-------------------------------------------------------
Commit a806a236c7224f755291413ed25f6b9bb92ddd71 in avro's branch
refs/heads/branch-1.12 from Steven Aerts
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=a806a236c7 ]
AVRO-4139 [java] equality check for maps in arrays (#3378)
With the introduction of the `AbstractArray` in avro 1.12, it was not
possible anymore to compare arrays which contained objects which
contained a Map, as the fact that we compared for equality was not
propagated anymore.
This commit re-introduces this propagation.
(cherry picked from commit a651bb2f5d8ad87e17fc66344a617d822b3611f3)
> [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
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> 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)