[ 
https://issues.apache.org/jira/browse/AVRO-3940?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17921378#comment-17921378
 ] 

Michel Davit commented on AVRO-3940:
------------------------------------

I think this needs to be re-opened. It is still affecting the {{Schema.Parser}}

In {{parseRecord}} the schema is added to the context 
[here|https://github.com/apache/avro/blob/8c27801dc8d42ccc00997f25c0b8f45f8d4a233e/lang/java/avro/src/main/java/org/apache/avro/Schema.java#L1865]
 before the fields, properties and logical types are populated.

The check in the {{ParseContext}} 
[here|https://github.com/apache/avro/blob/8c27801dc8d42ccc00997f25c0b8f45f8d4a233e/lang/java/avro/src/main/java/org/apache/avro/ParseContext.java#L218]
 will always fail because the schema passed as argument is not fully built. 


> Failed to generate Java classes from multiple .avsc files containing same type
> ------------------------------------------------------------------------------
>
>                 Key: AVRO-3940
>                 URL: https://issues.apache.org/jira/browse/AVRO-3940
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.11.3
>            Reporter: Patrick Wolleb
>            Priority: Major
>             Fix For: 1.12.0
>
>         Attachments: avsc-java-generator.zip, programmes-key.avsc, 
> programmes-value.avsc
>
>
> 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.
>  * schema 1:  [^programmes-key.avsc]
>  * schema 2: [^programmes-value.avsc]
> 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:*
>  # Download [^avsc-java-generator.zip]
>  # Unzip and change into directory
>  # Run ./gradlew quarkusDev --stacktrace
>  # Observe SchemaParseException in output
> *Expected:*
> The generator should accept the same name and overwrite the output.
> *Result:*
> {code:java}
> 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)  
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to