FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

Improve error message in AvroAliasTest #441

Closed apupier closed 8 months ago

apupier commented 8 months ago

it gives the reason of schema incompatibility when the schema is expected to be compatible. It can help investigation on #167

difference of output when test is faling (for isntance when upgrading avro dependency to 1.9): current main branch;

[ERROR]   AvroAliasTest.testAliasedRecordForwardsCompatible:69 expected:<[]COMPATIBLE> but was:<[IN]COMPATIBLE>

with this Pull Request:

[ERROR]   AvroAliasTest.testAliasedRecordForwardsCompatible:69->checkSchemaIsCompatible:119 Expected schema to be compatible but was not. Reason:
Data encoded using writer schema:
{
  "type" : "record",
  "name" : "Employee",
  "namespace" : "com.fasterxml.jackson.dataformat.avro.AvroTestBase",
  "fields" : [ {
    "name" : "name",
    "type" : "string"
  }, {
    "name" : "age",
    "type" : "int"
  }, {
    "name" : "emails",
    "type" : {
      "type" : "array",
      "items" : "string",
      "java-class" : "[Ljava.lang.String;"
    }
  }, {
    "name" : "boss",
    "type" : "Employee"
  } ]
}
will or may fail to decode using reader schema:
{
  "type" : "record",
  "name" : "NewEmployee",
  "namespace" : "com.fasterxml.jackson.dataformat.avro.interop.annotations.AvroAliasTest",
  "fields" : [ {
    "name" : "name",
    "type" : "string"
  }, {
    "name" : "age",
    "type" : "int"
  }, {
    "name" : "emails",
    "type" : {
      "type" : "array",
      "items" : "string",
      "java-class" : "[Ljava.lang.String;"
    }
  }, {
    "name" : "boss",
    "type" : "NewEmployee"
  } ],
  "aliases" : [ "com.fasterxml.jackson.dataformat.avro.AvroTestBase$.Employee" ]
}
cowtowncoder commented 8 months ago

Makes sense, thanks!