[Issue]: NullPointerException for enum type
See original GitHub issueWhat happened?
When I try so send a message with an enum I get an error. All the other fields work fine.
The Schema is:
{ "type": "record", "name": "MyFruitsValue", "namespace": "de.mycomp.avro.model", "fields": [ { "name": "aggregateAttribute", "type": { "type": "record", "name": "AggregateAttribute", "fields": [ { "name": "fruitList", "type": [ "null", { "type": "record", "name": "FruitList", "fields": [ { "name": "fruits", "type": [ "null", { "type": "array", "items": { "type": "record", "name": "Fruit", "fields": [ { "name": "fruitType", "type": [ "null", { "type": "enum", "name": "FruitType", "symbols": [ "MY_ENUM_1", "MY_ENUM_2", "MY_ENUM_3" ] } ], "default": null } ] } } ], "default": null } ] } ], "default": null } ] } } ] }
Maybe also of interest, loading the subject doesn’t work for the most fields. Only the top level elements get loaded correctly, the other elements (everything below aggregateAttribute for example) don’t work, so I had to enter the fields manually. But like I said, it worked for everything (also for another object in fruits array) but not for the enum. jmx.zip
KloadGen Version
KLoadGen 4.8.1
Relevant log output
org.apache.kafka.common.errors.SerializationException: Error serializing Avro message
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:154) ~[kloadgen-4.8.1.jar:?]
at io.confluent.kafka.serializers.KafkaAvroSerializer.serialize(KafkaAvroSerializer.java:61) ~[kloadgen-4.8.1.jar:?]
at org.apache.kafka.common.serialization.Serializer.serialize(Serializer.java:62) ~[kloadgen-4.8.1.jar:?]
at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:945) ~[kloadgen-4.8.1.jar:?]
at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:905) ~[kloadgen-4.8.1.jar:?]
at net.coru.kloadgen.sampler.KafkaSchemaSampler.runTest(KafkaSchemaSampler.java:164) [kloadgen-4.8.1.jar:?]
at org.apache.jmeter.protocol.java.sampler.JavaSampler.sample(JavaSampler.java:197) [ApacheJMeter_java.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.1]
at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.NullPointerException: null of de.mycomp.avro.model.FruitType of union in field fruitType of de.mycomp.avro.model.Fruit of array of union in field fruits of de.mycomps.avro.model.FruitList of union in field fruitList of de.mycomp.avro.model.AggregateAttribute in field aggregateAttribute of de.mycomp.avro.model.MyFruitsValue
at org.apache.avro.generic.GenericDatumWriter.npe(GenericDatumWriter.java:184) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:178) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73) ~[kloadgen-4.8.1.jar:?]
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.writeDatum(AbstractKafkaAvroSerializer.java:168) ~[kloadgen-4.8.1.jar:?]
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:146) ~[kloadgen-4.8.1.jar:?]
... 11 more
Caused by: java.lang.NullPointerException
at org.apache.avro.Schema$EnumSchema.getEnumOrdinal(Schema.java:1060) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeEnum(GenericDatumWriter.java:242) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:134) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:145) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:221) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeArray(GenericDatumWriter.java:257) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:137) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:145) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:221) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:145) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:221) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeField(GenericDatumWriter.java:221) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeRecord(GenericDatumWriter.java:210) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.writeWithoutConversion(GenericDatumWriter.java:131) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:83) ~[kloadgen-4.8.1.jar:?]
at org.apache.avro.generic.GenericDatumWriter.write(GenericDatumWriter.java:73) ~[kloadgen-4.8.1.jar:?]
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.writeDatum(AbstractKafkaAvroSerializer.java:168) ~[kloadgen-4.8.1.jar:?]
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:146) ~[kloadgen-4.8.1.jar:?]
... 11 more
Have you added your JMX Testplan or a replica?
- I have added a JMX testplan
Have you added your Schema or a replica?
- I have added the Schema
Issue Analytics
- State:
- Created a year ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
@Perry45, my apologies, push didn’t reach out. Now you should have them. Cheers
@jemacineiras WOW. It works! Great. Thank you, for your the fix 😃