You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/03/02 09:10:20 UTC

[GitHub] [pulsar] shiv4289 commented on issue #6419: auto_consume for avro crashes in decode (updated producer .class, old consumer schema .class)

shiv4289 commented on issue #6419: auto_consume for avro crashes in decode (updated producer .class, old consumer schema .class)
URL: https://github.com/apache/pulsar/issues/6419#issuecomment-593298037
 
 
   Fixed with this in the consumer code:
   
   ```
               String avroGeneratedClassName = genericAvroRecord.getAvroRecord().getSchema().getFullName();
               Class<?> avroGeneratedClass = Class.forName(avroGeneratedClassName);
   
               org.apache.pulsar.shade.org.apache.avro.Schema writerSchema = new Parser().parse(new String(schemaProvider.getSchemaByVersion(msg.getSchemaVersion()).get().getSchema()));
   
               org.apache.avro.Schema avroNativeReaderSchema = (org.apache.avro.Schema) avroGeneratedClass.getDeclaredField("SCHEMA$").get(null);
               org.apache.pulsar.shade.org.apache.avro.Schema readerSchema = new Parser().parse(avroNativeReaderSchema.toString());
   
               AvroReader avroReader = new AvroReader(writerSchema, readerSchema);
               return avroReader.read(msg.getData());
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services