We must explicitly require the user to supply the schema -- even though it is readily available through T -- because
of Java's type erasure. Unfortunately we cannot use Scala's TypeTag or Manifest features because these will add
(implicit) constructor parameters to actual Java class that implements T, and this behavior will cause Kafka's
mechanism to instantiate T to fail because it cannot find a constructor whose only parameter is a
kafka.utils.VerifiableProperties. Again, this is because Scala generates Java classes whose constructors always
include the Manifest/TypeTag parameter in addition to the normal ones. For this reason we haven't found a better
way to instantiate a correct SpecificDatumReader[T] other than explicitly passing a Schema parameter.
T
The type of the record, which must be backed by an Avro schema (passed via schema)
We must explicitly require the user to supply the schema -- even though it is readily available through T -- because of Java's type erasure. Unfortunately we cannot use Scala's
TypeTagorManifestfeatures because these will add (implicit) constructor parameters to actual Java class that implements T, and this behavior will cause Kafka's mechanism to instantiate T to fail because it cannot find a constructor whose only parameter is akafka.utils.VerifiableProperties. Again, this is because Scala generates Java classes whose constructors always include the Manifest/TypeTag parameter in addition to the normal ones. For this reason we haven't found a better way to instantiate a correctSpecificDatumReader[T]other than explicitly passing aSchemaparameter.The type of the record, which must be backed by an Avro schema (passed via
schema)