Avro
  1. Avro
  2. AVRO-667

GenericArray fails to compare with List. SpecificRecord compare gets ClassCastException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.4.0
    • Fix Version/s: 1.4.1
    • Component/s: java
    • Labels:
      None

      Description

      AVRO-637 is incomplete.

      I am unable to convert my SpecificRecord project to 1.4. It compiles, but unit tests get runtime exceptions.

      compareTo in GenericData does not handle List vs GenericArray and I get class cast exceptions.

      java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.apache.avro.generic.GenericArray
      	at org.apache.avro.generic.GenericData.compare(GenericData.java:502)
      	at org.apache.avro.specific.SpecificData.compare(SpecificData.java:190)
      	at org.apache.avro.generic.GenericData.compare(GenericData.java:494)
      	at org.apache.avro.specific.SpecificData.compare(SpecificData.java:190)
      	at org.apache.avro.specific.SpecificRecordBase.compareTo(SpecificRecordBase.java:45)
      	at org.apache.avro.specific.SpecificRecordBase.equals(SpecificRecordBase.java:35)
      	at com.rr.eventdata.ViewRecord.equals(ViewRecord.java:350)
      	at com.rr.eventdata.WriteStuffTest.main(WriteStuffTest.java:143)
      	at com.rr.eventdata.WriteStuffTest.testReadWriteDataFile(WriteStuffTest.java:55)
      

      Also, an array of string in SpecificRecord ends up as List<CharSequence>.
      However, it should be List<? extends CharSequence> or else you can't assign a List<String> to it.

      1. AVRO-667.patch
        7 kB
        Doug Cutting
      2. AVRO-667.patch
        7 kB
        Doug Cutting
      3. AVRO-667.patch
        7 kB
        Scott Carey
      4. AVRO-667.patch
        6 kB
        Scott Carey

        Activity

        Scott Carey created issue -
        Scott Carey made changes -
        Field Original Value New Value
        Attachment AVRO-667.patch [ 12454738 ]
        Scott Carey made changes -
        Attachment AVRO-667.patch [ 12454740 ]
        Doug Cutting made changes -
        Attachment AVRO-667.patch [ 12454784 ]
        Doug Cutting made changes -
        Attachment AVRO-667.patch [ 12454793 ]
        Scott Carey made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Doug Cutting made changes -
        Component/s java [ 12312780 ]
        Doug Cutting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Scott Carey
            Reporter:
            Scott Carey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development