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

Json output doesn't generate base64 for byte arrays

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 1.7.7
    • Fix Version/s: None
    • Component/s: java
    • Labels:
      None
    • Environment:

      Pure java.

      Description

      The Json output of java generated code doesn't correctly encode byte arrays.

      Using this simple schema :
      {"namespace": "example.avro",
      "type": "record",
      "name": "ByteArrayEncoding",
      "fields": [

      {"name": "data", "type": "bytes"}

      ]
      }

      The toString()
      System.out.println(new ByteArrayEncoding(ByteBuffer.wrap(new byte[]

      {0,31,65,66,67,(byte)255,(byte)182}

      )));

      Returns raw bytes to string in the json :
      {"data": {"bytes": " ABC??"}}

      As a byte array is not tied to be a valid string, it should be converted back and forth to Base64 like other Json implementations :

      {"data": {"bytes": "AB9BQkP/tg=="}}

        Attachments

        1. AVRO-1584.1.patch
          3 kB
          Ryan Blue
        2. AVRO-1584.patch
          4 kB
          David Lemieux
        3. AVRO-1584-Jackson-Base64-Default-Variant.patch
          4 kB
          David Lemieux

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              killertoffy Christophe Lorenz
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: