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

SpecificRecord decoding fails if Java keyword is used as record name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.10.0
    • None
    • java

    Description

      Someone created an Avro definition where the name of a record is case:

      protocol Proto {
          record case {
              string value;
          }
      
          record Wrapper {
              case inner;
          }
      }
      

      Code generation works and the generated Java code uses case$ for the class name of the record. There is no problem in writing the Java code itself, however, decoding with a SpecificRecord.getDecoder() fails with a ClassCastException:

      class org.apache.avro.generic.GenericData$Record cannot be cast to class case$ (org.apache.avro.generic.GenericData$Record and case$ are in unnamed module of loader 'app')
      java.lang.ClassCastException: class org.apache.avro.generic.GenericData$Record cannot be cast to class case$ (org.apache.avro.generic.GenericData$Record and case$ are in unnamed module of loader 'app')
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Fleshgrinder Richard Fussenegger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

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