AvroItemWriter uses GenericDatumWriter instead of SpecificDatumWriter for type that extends SpecificRecordBase #3859
Labels
for: backport-to-4.2.x
Issues that will be back-ported to the 4.2.x line
in: infrastructure
type: bug
Bug description
I am generating Java code from an Avro schema. It creates classes that extend SpecificRecordBase. In this case AvroItemWriter automatically chooses GenericDatumWriter as the underlying writer. This causes multiple exceptions when logical types are used in the schema (for example decimal or timestamp-millis).
It would work perfectly if SpecificDatumWriter is used. I believe that the problem lies in the order in which datum writer is chosen. The code checks first if my item class is an instance of GenericRecord and only after that returns false, it check if it is an instance of SpecificRecordBase. As SpecificRecordBase implements GenericRecord the first check will always return true and this leads to GenericDatumWriter to be used.
Environment
Spring Batch 4.3.1
Steps to reproduce
Expected behavior
SpecificDatumWriter should be used instead of GenericDatumWriter.
The text was updated successfully, but these errors were encountered: