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

toString generates poorly formatted defaults for bytes

    XMLWordPrintableJSON

Details

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

    Description

      Schema#toString and Protocol#toString both generate default values for "bytes" and "fixed" types.

      According to docs:

      Default values for bytes and fixed fields are JSON strings, where Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255. Avro encodes a field even if its value is equal to its default.

      The following schema

      {
        "type" : "record",
        "name" : "TestRecord",
        "fields" : [ {
          "name" : "testFixed",
          "type" : {
            "type" : "fixed",
            "name" : "Code",
            "size" : 3
          },
          "default" : "\u0009\u0020\u00FF"
        } ]
      }

      If parsed and then again encoded to JSON would have "\t ÿ" value in "default".

      It happens because `toString` implementations use `JsonGenerator` with default escape configs.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              roman.mitasov Roman Mitasov
              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 - 20m
                  20m