Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
When we are validating AVRO schema against payload we just get one failed attribute information only. While in case of multiple attribute failure for a big schema it becomes difficult to correct the payload. Can it be corrected in the library so that we get all the information as in JSON we get.
Schema ::
{ "namespace": "tutorialspoint.com", "type": "record", "name": "emp", "fields": [ \{"name": "name", "type": "string"},
{"name": "id", "type": "int"},
{"name": "salary", "type": "int"},
{"name": "age", "type": "int"},
{"name": "address", "type": "string"}
]
}
Test cases:
Test case 1.
Success Payload
{"emp":{"name":"alex","id":2,"age":23,"salary":2000,"address":"xyz"}}
Test case 2.
Failure payload with 2 attributes wrong type(Address and salary)::
{"emp":{"name":"alex","id":2,"age":23,"salary":"Twenty thousand","address":123}}
Code implemented:
Schema schema = new Schema.Parser().parse(strSchema);
try
catch (AvroRuntimeException e)
{ throw new SerializationException("AVRO does not match schema ", e); }Problem:
we want to get all the failures while validating the AVRO schema against payload. The avro library used in above code returns only one failure.
But in the Test case 2 in exception it just returns one failure not both.