Avro
  1. Avro
  2. AVRO-1275

GenericData's toString() method generates the wrong JSON encoding for the bytes type

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1.8.0
    • Component/s: java
    • Labels:
      None

      Description

      We discovered in AVRO-1274 that for bytes GenericData.toString(Object datum) incorrectly generates

      { "bytes" : "A" }
      

      rather than just "A" for the JSON encoding defined in the spec (http://avro.apache.org/docs/current/spec.html#json_encoding).

        Issue Links

          Activity

          Hide
          Doug Cutting added a comment -

          Also note that the json_encoding mentioned in the description is not totally relevant here, since that tags union values and GenericData#toString() does not.

          The more relevant part of the specification is the description of default values (http://avro.apache.org/docs/current/spec.html#schema_complex). Union branches are not represented in default values (the first branch is always assumed). So GenericData#toString() should match the format for default values, and does, except for this bug.

          Show
          Doug Cutting added a comment - Also note that the json_encoding mentioned in the description is not totally relevant here, since that tags union values and GenericData#toString() does not. The more relevant part of the specification is the description of default values ( http://avro.apache.org/docs/current/spec.html#schema_complex ). Union branches are not represented in default values (the first branch is always assumed). So GenericData#toString() should match the format for default values, and does, except for this bug.
          Hide
          Doug Cutting added a comment -

          This is a bug, but fixing it would be an incompatible change, so should probably wait until release 1.8.

          Show
          Doug Cutting added a comment - This is a bug, but fixing it would be an incompatible change, so should probably wait until release 1.8.

            People

            • Assignee:
              Unassigned
              Reporter:
              Tom White
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Development