1

I currently having an issue with the Avro JsonDecoder. Avro is used in Version 1.8.2. The .avsc file is defined like:

{
"type": "record",
"namespace": "my.namespace",
"name": "recordName",
"fields": [
    {
        "name": "Code",
        "type": "string"
    },
    {
        "name": "CodeNumber",
        "type": "string",
        "default": ""
    }
  ]
}

When I now run my test cases I get an org.apache.avro.AvroTypeException: Expected string. Got END_OBJECT. The class throwing the error is JasonDecoder. For me it looks like the defaut value handling on my side might not be correct with using just "" as the default value. The error occurs only if the field is not available at all, but this, in my understanding, is the case when the default value should be used. If I set the value in the json as "CodeNumber": "" the decoder does not have any issues. Any hints or ideas?

fx88
  • 43
  • 1
  • 8

1 Answers1

0

Found this:

Turns out the issue is that the default values are just ignored by the java implementations. I've added a workaround which will catch the exception and then look for a default value. Will be in release 1.9.0

Source: https://github.com/sksamuel/avro4s/issues/106

If it is possible, try to upgrade your Avro Decoder to 1.9.0 version.

ish
  • 161
  • 7
  • Im using the `org.apache.avro` library. Your finding looks good but about the wrong lib. Neverthless I tried the upgrade to 1.9.2 but the problem still remains. – fx88 Apr 14 '20 at 15:19