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

Generated Avro schema from Protobuf is missing default values for repeated fields

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.9.2
    • 1.10.1
    • java
    • None
    • Patch

    Description

      Avro schemas generated from Protobuf schemas by ProtobufData.java are missing default values for repeated (array) fields.
      This will break compatibility when Avro is used as a transport format between 2 services that use Protobuf internally.
       
      For example:
      A publisher converts Protobuf to Avro, then sends the message through Kafka to a consumer. The consumer then converts Avro back into Protobuf, then does all the processing with Protobuf.
       
      A compatibility issue will occur when a new repeated Protobuf field is added to the consumer Protobuf schema. The corresponding Avro schema generated from

      Schema schema = ProtobufData.get().getSchema(MyProtobufClass.class);
      

       will not assign default values to the newly added repeated field. Because the publisher is still on the schema without the newly added array field, deserialization on the consumer side will fail since there is no default values to fill in.
       
       
       
      I discussed this with cutting on the mailing list and it makes sense to just add default values for Protobuf repeated fields.

      Attachments

        1. AVRO-2788.patch
          3 kB
          Tianyu Lang

        Issue Links

          Activity

            People

              tlang1991 Tianyu Lang
              tlang1991 Tianyu Lang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: