Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2943

Map comparison between Utf8 and String keys fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.10.0
    • 1.12.0, 1.11.2
    • java
    • 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)

    Description

      The following test I locally added to org.apache.avro.generic.TestGenericData on master demonstrates the problem:

        @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);
        }
      

      Attachments

        1. AVRO-2943-frankgrimes97.patch
          5 kB
          Frank Grimes

        Activity

          People

            frankgrimes97 Frank Grimes
            frankgrimes97 Frank Grimes
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 50m
                1h 50m