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

ReflectData still generates namespaces with dollar signs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.11.0
    • java
    • None

    Description

      ReflectData should always generate valid Avro schemas for Java classes.  Currently, the name and namespace are taken from the Java class name, which can contain dollar signs.  AVRO-2143 fixed this for the most common cases for nested classes.

      It's still possible to generate namespaces with a dollar sign for classes that are nested more than one level.  This can be observed in this unit test:

      https://github.com/apache/avro/blob/70260919426f89825ca148f5ee815f3b2cf4764d/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java#L842

      which generates

      {
        "type" : "record",
        "name" : "AnotherSampleRecord",
        "namespace" : "org.apache.avro.reflect.TestReflect$SampleRecord",
        "fields" : [ {
          "name" : "a",
          "type" : [ "null", "int" ],
          "default" : null
        }, {
          "name" : "s",
          "type" : [ "null", {
            "type" : "record",
            "name" : "SampleRecord",
            "namespace" : "org.apache.avro.reflect.TestReflect",
            "fields" : [ {
              "name" : "x",
              "type" : "int"
            }, {
              "name" : "y",
              "type" : "int"
            } ]
          } ],
          "default" : null
        } ]
      }
      

       

      Attachments

        Issue Links

          Activity

            People

              rskraba Ryan Skraba
              rskraba Ryan Skraba
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: