pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] shiv4289 commented on issue #6419: auto_consume for avro crashes in decode (updated producer .class, old consumer schema .class)
Date Mon, 02 Mar 2020 09:10:20 GMT
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

Mime
View raw message