[
https://issues.apache.org/jira/browse/AVRO-2943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17226900#comment-17226900
]
Frank Grimes edited comment on AVRO-2943 at 11/28/20, 6:30 PM:
---------------------------------------------------------------
I just realized that for the existing Schema.type.STRING handling hashCode is
also overridden:
[https://github.com/apache/avro/blob/6b55656b25cacf0d88cf44d9d802ce46dfaadc83/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java#L1090]
I think an equivalent hashCode change (and tests) might be in order.
For existing hashCode unit tests I only found the following:
[https://github.com/apache/avro/blob/release-1.10.0/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java#L96-L108]
Thoughts?
was (Author: frankgrimes97):
I just realized that for the existing Schema.type.STRING handling hashCode is
also overridden:
[https://github.com/apache/avro/blob/6b55656b25cacf0d88cf44d9d802ce46dfaadc83/lang/java/avro/src/main/java/org/apache/avro/generic/GenericData.java#L1090]
I think an equivalent hashCode change (and tests might be in order).
For existing hashCode unit tests I only found the following:
[https://github.com/apache/avro/blob/release-1.10.0/lang/java/avro/src/test/java/org/apache/avro/generic/TestGenericData.java#L96-L108]
Thoughts?
> Map comparison between Utf8 and String keys fails
> -------------------------------------------------
>
> Key: AVRO-2943
> URL: https://issues.apache.org/jira/browse/AVRO-2943
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.10.0
> Environment: Mac OS Catalina 10.15.6
>
> openjdk version "1.8.0_265"
> OpenJDK Runtime Environment Corretto-8.265.01.1 (build 1.8.0_265-b01)
> OpenJDK 64-Bit Server VM Corretto-8.265.01.1 (build 25.265-b01, mixed mode)
> Reporter: Frank Grimes
> Priority: Major
> Attachments: AVRO-2943-frankgrimes97.patch
>
>
> The following test I locally added to org.apache.avro.generic.TestGenericData
> on master demonstrates the problem:
> {code:java}
> @Test
> public void testMapKeyEquals() {
> Schema mapSchema = new Schema.Parser().parse("{\"type\": \"map\",
> \"values\": \"string\"}");
> Field myMapField = new Field("my_map", Schema.createMap(mapSchema), null,
> null);
> Schema schema = Schema.createRecord("my_record", "doc", "mytest", false);
> schema.setFields(Arrays.asList(myMapField));
> GenericRecord r0 = new GenericData.Record(schema);
> GenericRecord r1 = new GenericData.Record(schema);
> HashMap<CharSequence, String> pair1 = new HashMap<>();
> pair1.put("keyOne", "valueOne");
> r0.put("my_map", pair1);
> HashMap<CharSequence, String> pair2 = new HashMap<>();
> pair2.put(new Utf8("keyOne"), "valueOne");
> r1.put("my_map", pair2);
> assertEquals(r0, r1);
> assertEquals(r1, r0);
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)