You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Valentin (Jira)" <ji...@apache.org> on 2020/06/05 12:04:00 UTC

[jira] [Commented] (AVRO-2838) Schema in generated Java class is different than the original one

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

Valentin commented on AVRO-2838:
--------------------------------

I have the same issue.

For now my workaround is to convert the SCHEMA$ variable to JSON, cleanup the invalid properties and rebuild the SCHEMA.

For my use case, I can do this once for every schema on application startup so it works rather well.

But a fix would be nice.

To not break compatibility I suggest that a configuration property could me passed to the plugin in the pom to switch between : 
 * the current mode where the SCHEMA$ differs from the original schema used to build the class
 * the new mode implementing the fix where the SCHEMA$ is identical to the original schema used to build the class

Alternatively, if the modified $SCHEMA is fundamentally needed, we may have two variables ? An ORIGINAL_SCHEMA$ variable and the current $SCHEMA variable ?

> Schema in generated Java class is different than the original one
> -----------------------------------------------------------------
>
>                 Key: AVRO-2838
>                 URL: https://issues.apache.org/jira/browse/AVRO-2838
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>            Reporter: Lukas Krecan
>            Priority: Major
>         Attachments: AVRO.patch
>
>
> If you generate Java classes from schema, {{SCHEMA$}} variable differs from the original schema. It causes issues like [this|https://github.com/confluentinc/schema-registry/issues/868] and [this|https://github.com/confluentinc/schema-registry/issues/1352] when using Schema registry.
> The issue happens when the schema in the registry is configured externally and then you try to use generated Java class. The schema in the registry does not match the schema in the class and thus the write is refused.
> Technically it's easy to fix (see the attached patch) but I guess there will be some backward compatibility concerns. 
> If it is not acceptable, would it be at least possible to add the {{originalSchema}} context variable so we could solve it using custom template.
> The patch is not final, its purpose is just to convey the idea.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)