我有一个关于specificavrodeserializer的问题,因为类名,我一直假设specificavroserializer将产生specificrecord,specificavrodeserializer将能够使用它。
令我惊讶的是,如果我不设置'specific.avro.reader'属性,specificavrodeserializer尝试将字节数组作为genericrecord读取,因为类“abstractkafkaavrodeserializer”中有以下代码行(https://github.com/confluentinc/schema-registry/blob/master/avro-serializer/src/main/java/io/confluent/kafka/serializers/abstractkafkaavrodeserializer.java)..
private DatumReader getDatumReader(Schema writerSchema, Schema readerSchema) {
boolean writerSchemaIsPrimitive =
AvroSchemaUtils.getPrimitiveSchemas().values().contains(writerSchema);
// do not use SpecificDatumReader if writerSchema is a primitive
if (useSpecificAvroReader && !writerSchemaIsPrimitive) {
if (readerSchema == null) {
readerSchema = getReaderSchema(writerSchema);
}
return new SpecificDatumReader(writerSchema, readerSchema);
} else {
if (readerSchema == null) {
return new GenericDatumReader(writerSchema);
}
return new GenericDatumReader(writerSchema, readerSchema);
}
}
我以为具体的avroDeserializer的构造函数应该设置这个,但它没有(https://github.com/confluentinc/schema-registry/blob/master/avro-serde/src/main/java/io/confluent/kafka/streams/serdes/avro/specificavrodeserializer.java)
那我还缺什么?
暂无答案!
目前还没有任何答案,快来回答吧!