Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-4062

Idl parsing not recognizing leading underscore for field names

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.12.0
    • None
    • java

    Description

      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.

      line 94:9 token recognition error at: '_'

      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:

      @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());
      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              isak Isak Lindbeck
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m