Isak Lindbeck created AVRO-4062:
-----------------------------------

             Summary: 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


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