Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.11.2
Description
The rewritten map comparison implementation in GenericData (AVRO-2943 according to the commit message) throws a NoSuchElementException when used to compare empty maps. Partial stacktrace:
Caused by: java.util.NoSuchElementException at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1513) at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1534) at org.apache.avro.generic.GenericData.compareMaps(GenericData.java:1163) at org.apache.avro.generic.GenericData.compare(GenericData.java:1250) at org.apache.avro.specific.SpecificData.compare(SpecificData.java:476) at org.apache.avro.generic.GenericData.compare(GenericData.java:1229) at org.apache.avro.specific.SpecificData.compare(SpecificData.java:476) at org.apache.avro.specific.SpecificRecordBase.equals(SpecificRecordBase.java:88) at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:133) at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:119) at org.scalactic.DefaultEquality$.areEqualComparingArraysStructurally(DefaultEquality.scala:70) at org.scalactic.DefaultEquality.areEqual(DefaultEquality.scala:37) at org.mockito.package$$anon$2.areEqual(mockito.scala:614) at org.scalactic.TripleEqualsSupport$Equalizer.$eq$eq$eq(TripleEqualsSupport.scala:117) at org.mockito.matchers.EqTo.matches(EqTo.scala:11) ...
Also, the check in line 1170 that's intended to shortcircuit for maps of different sizes is incorrect. Because of this, maps will incorrectly compare equal when:
- their sizes are different
- one is a superset of the other map
Attachments
Issue Links
- is duplicated by
-
AVRO-3792 GenericData compare fails for Maps size = 0 or sizes not same
- Resolved
- links to