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

ASF subversion and git services commented on AVRO-4062:
-------------------------------------------------------

Commit ed6d4b74173a10bbddabf1dbe6929c89a9b98df6 in avro's branch 
refs/heads/main from Isak Lindbeck
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=ed6d4b741 ]

AVRO-4062: Allow leading underscores for names in idl (#3178)

* AVRO-4062 [java] Fix broken test data

* AVRO-4062 [java] Make maven run unit test for IdlReader

The test is not run automatically unless the class naming convention is followed

* AVRO-4062 Allow leading underscore for names in idl

* AVRO-4062 [java] Add test for leading underscore in names

---------

Co-authored-by: Isak Lindbeck <[email protected]>

> Idl parsing not recognizing leading underscore for field names
> --------------------------------------------------------------
>
>                 Key: AVRO-4062
>                 URL: https://issues.apache.org/jira/browse/AVRO-4062
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.12.0
>            Reporter: Isak Lindbeck
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> With version 1.12.0 the avro-maven-plugin stopped parsing leading underscore 
> for field names. This was not the case for version 1.11.3
> The following error can be observed.
> {code:java}
> line 94:9 token recognition error at: '_'{code}
> This should be allowed according to the specification for field names:
>  * start with [A-Za-z_]
>  * subsequently contain only [A-Za-z0-9_]
> I can reproduce the issue with this test:
> {code:java}
> @Test
> void testParsingLeadingUnderscore() throws IOException {
>     String avdl = """
>         @namespace("com.example.avro.schema")
>         record Example {
>             string _field;
>         }
>         """;
>     var byteStream = new ByteArrayInputStream(avdl.getBytes(UTF_8));
>     IdlFile parse = new IdlReader().parse(byteStream);
>     Schema schema = parse.getNamedSchema("com.example.avro.schema.Example");
>     // Fails since actual field name does not have a leading underscore
>     assertEquals("_field", schema.getFields().get(0).name());
> }{code}



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

Reply via email to