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 2022/03/04 09:19:28 UTC

[GitHub] [pulsar] patricklucas commented on issue #9718: Avro "fixed" field causes ClassCastException

patricklucas commented on issue #9718:
URL: https://github.com/apache/pulsar/issues/9718#issuecomment-1058983997


   This still occurs on latest Pulsar.
   
   I've updated the repo with the reproducing example to upgrade to Pulsar 2.9.1 and to make it easier to run:
   - `docker-compose up -d` will run Pulsar in standalone mode locally
   - `./gradlew :runTweetProducer` will run the example
   
   Full output:
   
   ```
   $ docker-compose up -d
   [+] Running 2/2
    ⠿ Network pulsar-avro-schema-example_default     Created                                                                                                                                                                                                                              0.0s
    ⠿ Container pulsar-avro-schema-example-pulsar-1  Started 
   $ ./gradlew :runTweetProducer
   
   > Task :runTweetProducer
   ...
   Tweet JSON: {
     "username" : "user-0",
     "tweet" : "tweet-0",
     "fixed" : "Hello",
     "timestamp" : 1646385474269
   }
   org.apache.pulsar.client.api.SchemaSerializationException: java.lang.ClassCastException: class org.apache.pulsar.examples.Fixed cannot be cast to class org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed (org.apache.pulsar.examples.Fixed and org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed are in unnamed module of loader 'app') in field fixed
           at org.apache.pulsar.client.impl.schema.writer.AvroWriter.write(AvroWriter.java:55)
           at org.apache.pulsar.client.impl.schema.AbstractStructSchema.encode(AbstractStructSchema.java:57)
           at org.apache.pulsar.client.impl.TypedMessageBuilderImpl.value(TypedMessageBuilderImpl.java:175)
           at org.apache.pulsar.client.impl.ProducerBase.send(ProducerBase.java:64)
           at org.apache.pulsar.examples.TweetProducer.main(TweetProducer.java:42)
   Caused by: java.lang.ClassCastException: class org.apache.pulsar.examples.Fixed cannot be cast to class org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed (org.apache.pulsar.examples.Fixed and org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed are in unnamed module of loader 'app') in field fixed
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.addClassCastMsg(GenericDatumWriter.java:191)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:229)
           at org.apache.pulsar.shade.org.apache.avro.specific.SpecificDatumWriter.writeField(SpecificDatumWriter.java:101)
           at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectDatumWriter.writeField(ReflectDatumWriter.java:184)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210)
           at org.apache.pulsar.shade.org.apache.avro.specific.SpecificDatumWriter.writeRecord(SpecificDatumWriter.java:83)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83)
           at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:158)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73)
           at org.apache.pulsar.client.impl.schema.writer.AvroWriter.write(AvroWriter.java:53)
           ... 4 more
   Caused by: java.lang.ClassCastException: class org.apache.pulsar.examples.Fixed cannot be cast to class org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed (org.apache.pulsar.examples.Fixed and org.apache.pulsar.shade.org.apache.avro.generic.GenericFixed are in unnamed module of loader 'app')
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeFixed(GenericDatumWriter.java:362)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:148)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83)
           at org.apache.pulsar.shade.org.apache.avro.reflect.ReflectDatumWriter.write(ReflectDatumWriter.java:158)
           at org.apache.pulsar.shade.org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:221)
           ... 13 more
   
   BUILD SUCCESSFUL in 6s
   4 actionable tasks: 1 executed, 3 up-to-date
   ```


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org