In certain scenarios when there is a serialization error, avro serializer gives following error messages that are not actionable without any schema name and/field name in it.
- java.lang.Double cannot be cast to java.lang.Long
- Not an enum: null
If there is a filed name of specific schema that is causing these serialization errors, that helps to fix such issues quickly.
The "writeWithoutConversion" method of "GenericDatumWriter" class can be updated to handle "ClassCastException" along with "NullPointerException" to throw an exception with schema name and field name.
The "writeEnum", "writeField", and "error" method can be enhanced to add field names so that error message can have the field that is causing the issue.