[ 
https://issues.apache.org/jira/browse/AVRO-3698?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Tzvetanov Grigorov updated AVRO-3698:
--------------------------------------------
    Description: 
[Java] SpecificData.getClassName must replace reserved words

 

When makes Java Class, SpecificCompiler adds "$" after reserved words like 
public, new, etc...

[https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L1129]

[https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L643]

 

For example, if the namespace of a schema is {*}db.public.table{*}, then the 
package name of the generated Java Class, made by SpecificCompiler, is 
{*}db.public$.table{*}. (Because *public* is a reserved word in java)

 

But when deserializes an Avro Record to a SpecificRecord, 
SpecificData.getClassName returns {*}db.public.table.Name{*}.

 

So, it can't find a class by name from SpecificData.getClassName.

  was:
[Java] SpecificData.getClassName must replace reserved words

 

When makes Java Class, SpecificCompiler adds "$" after reserved words like 
public, new, etc...

[https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L1129]

[https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L643]

 

For example, if the namespace of a schema is {*}db.public.table{*}, then the 
package name of the generated Java Class, made by SpecificCompiler, is 
{*}db.public$.table{*}. (Because *public* is a reserved word in java)

 

But when deserializes an Avro Record to a SpecificRecord, 
SpecificData.getClassName returns {*}db.pulic.table.Name{*}.

 

So, it can't find a class by name from SpecificData.getClassName.


> [Java] SpecificData.getClassName must replace reserved words
> ------------------------------------------------------------
>
>                 Key: AVRO-3698
>                 URL: https://issues.apache.org/jira/browse/AVRO-3698
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.11.1
>            Reporter: Seung-Hyun Cheong
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Major
>              Labels: newbie, patch, pull-request-available
>             Fix For: 1.12.0, 1.11.2
>
>         Attachments: AVRO-3698.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> [Java] SpecificData.getClassName must replace reserved words
>  
> When makes Java Class, SpecificCompiler adds "$" after reserved words like 
> public, new, etc...
> [https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L1129]
> [https://github.com/apache/avro/blob/master/lang/java/compiler/src/main/java/org/apache/avro/compiler/specific/SpecificCompiler.java#L643]
>  
> For example, if the namespace of a schema is {*}db.public.table{*}, then the 
> package name of the generated Java Class, made by SpecificCompiler, is 
> {*}db.public$.table{*}. (Because *public* is a reserved word in java)
>  
> But when deserializes an Avro Record to a SpecificRecord, 
> SpecificData.getClassName returns {*}db.public.table.Name{*}.
>  
> So, it can't find a class by name from SpecificData.getClassName.



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

Reply via email to