Avro
  1. Avro
  2. AVRO-1473

Nested schema reference with empty namespace cannot be parsed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.7
    • Component/s: java
    • Labels:
      None

      Description

      Related to AVRO-1295, a reference to a nested named schema with an empty namespace cannot be parsed. An example of such a schema is as follows:

      {
        "type" : "record",
        "name" : "Outer",
        "namespace" : "space",
        "fields" : [ {
          "name" : "f1",
          "type" : {
            "type" : "record",
            "name" : "Inner",
            "namespace" : "",
            "fields" : [ ]
          }
        }, {
          "name" : "f2",
          "type" : "Inner"
        } ]
      }
      

      Attempting to parse this results in the following exception:

      org.apache.avro.SchemaParseException: "Inner" is not a defined name. The type of the "f2" field must be a defined name or a {"type": ...} expression.

      The issue seems to be that the lookup for the name "Inner" is done with the namspace of the encoding record, and not with the empty namespace for this case.

      1. AVRO-1473.patch
        5 kB
        Gabriel Reid

        Activity

        Hide
        Hudson added a comment -

        SUCCESS: Integrated in AvroJava #445 (See https://builds.apache.org/job/AvroJava/445/)
        AVRO-1473. Java: Fix references to names in the empty namespace. Contributed by Gabriel Reid. (cutting: rev 1577275)

        • /avro/trunk/CHANGES.txt
        • /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
        • /avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
        Show
        Hudson added a comment - SUCCESS: Integrated in AvroJava #445 (See https://builds.apache.org/job/AvroJava/445/ ) AVRO-1473 . Java: Fix references to names in the empty namespace. Contributed by Gabriel Reid. (cutting: rev 1577275) /avro/trunk/CHANGES.txt /avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java /avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
        Hide
        Doug Cutting added a comment -

        I committed this. Thanks, Gabriel!

        Show
        Doug Cutting added a comment - I committed this. Thanks, Gabriel!
        Hide
        ASF subversion and git services added a comment -

        Commit 1577275 from Doug Cutting in branch 'avro/trunk'
        [ https://svn.apache.org/r1577275 ]

        AVRO-1473. Java: Fix references to names in the empty namespace. Contributed by Gabriel Reid.

        Show
        ASF subversion and git services added a comment - Commit 1577275 from Doug Cutting in branch 'avro/trunk' [ https://svn.apache.org/r1577275 ] AVRO-1473 . Java: Fix references to names in the empty namespace. Contributed by Gabriel Reid.
        Hide
        Gabriel Reid added a comment -

        Patch to resolve this issue. The approach taken is to attempt to retrieve the name with the enclosing record's namespace, and if that fails, the name lookup is attempted with the empty namespace.

        Show
        Gabriel Reid added a comment - Patch to resolve this issue. The approach taken is to attempt to retrieve the name with the enclosing record's namespace, and if that fails, the name lookup is attempted with the empty namespace.

          People

          • Assignee:
            Gabriel Reid
            Reporter:
            Gabriel Reid
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development