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

Failed to generate Java classes from multiple .avsc files containing same type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Workaround
    • 1.11.3
    • 1.12.0
    • java
    • None

    Description

      I am unable to generate Java classes from two .avsc files that both contain an identical record. I get a SchemaParseException: Can't redefine: com.example.domain.Provenance.

      I am not sure I understand the generator correctly since the the check to throw the exception in this case was recently added for the code generation via an Open API yaml https://issues.apache.org/jira/browse/AVRO-3805

      Here the commit in question:

      https://github.com/apache/avro/blame/c60e1a0cbf98412b1c65cb2d9029d32077d85574/lang/java/avro/src/main/java/org/apache/avro/Schema.java#L1753

      clesaec 

      Steps to reproduce:

      1. Download avsc-java-generator.zip
      2. Unzip and change into directory
      3. Run ./gradlew quarkusDev --stacktrace
      4. Observe SchemaParseException in output

      Expected:

      The generator should accept the same name and overwrite the output.

      Result:

      Caused by: org.apache.avro.SchemaParseException: Can't redefine: com.example.domain.Provenance     at org.apache.avro.Schema$Names.put(Schema.java:1604)     at org.apache.avro.Schema$Names.add(Schema.java:1598)     at org.apache.avro.Schema.parse(Schema.java:1774)     at org.apache.avro.Schema.parse(Schema.java:1736)     at org.apache.avro.Schema$Parser.parse(Schema.java:1471)     at org.apache.avro.Schema$Parser.parse(Schema.java:1433)  
      

       

       

      Attachments

        1. avsc-java-generator.zip
          753 kB
          Patrick Wolleb
        2. programmes-value.avsc
          0.6 kB
          Patrick Wolleb
        3. programmes-key.avsc
          0.6 kB
          Patrick Wolleb

        Activity

          People

            Unassigned Unassigned
            pwollebsrf Patrick Wolleb
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: