Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in AbstractKafkaDeserializer when using serdes 2.2.5 #2641

Closed
ajborley opened this issue Jul 21, 2022 · 0 comments · Fixed by #2642
Closed

NullPointerException in AbstractKafkaDeserializer when using serdes 2.2.5 #2641

ajborley opened this issue Jul 21, 2022 · 0 comments · Fixed by #2642

Comments

@ajborley
Copy link
Contributor

Line 119 of the AbstractKafkaDeserializer class is failing with an NPE when running a Kafka consumer client with the "apicurio.registry.headers.enabled" property set to false.

I think the Kafka headers object at line 118 is empty, but not null, meaning that the code attempts to access the headersHandler object at line 119 which has never been initialized in this code block in the AbstractKafkaSerDe class due to the headers.enabled property.

The NPE stack is:

org.apache.kafka.common.errors.SerializationException: Error deserializing key/value for partition testtopich-0 at offset 29. If needed, please seek past the record to continue consumption.
Caused by: java.lang.NullPointerException
	at io.apicurio.registry.serde.AbstractKafkaDeserializer.deserialize(AbstractKafkaDeserializer.java:119)
	at org.apache.kafka.clients.consumer.internals.Fetcher.parseRecord(Fetcher.java:1386)
	at org.apache.kafka.clients.consumer.internals.Fetcher.access$3400(Fetcher.java:133)
	at org.apache.kafka.clients.consumer.internals.Fetcher$CompletedFetch.fetchRecords(Fetcher.java:1617)
	at org.apache.kafka.clients.consumer.internals.Fetcher$CompletedFetch.access$1700(Fetcher.java:1453)
	at org.apache.kafka.clients.consumer.internals.Fetcher.fetchRecords(Fetcher.java:686)
	at org.apache.kafka.clients.consumer.internals.Fetcher.fetchedRecords(Fetcher.java:637)
	at org.apache.kafka.clients.consumer.KafkaConsumer.pollForFetches(KafkaConsumer.java:1303)
	at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1237)
	at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1210)

And my consumer client properties are:

props.put(SerdeConfig.ENABLE_HEADERS, false);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, AvroKafkaDeserializer.class);
props.put(AvroKafkaSerdeConfig.USE_SPECIFIC_AVRO_READER, true);
ajborley added a commit to ajborley/apicurio-registry that referenced this issue Jul 21, 2022
- Kafka passes an empty, but non-null Headers object to the
Deserializer, which can cause an NPE when the headersHandler
has not been initialized (which occurs when the
`apicurio.registry.headers.enabled` property is set to
false).

Contributes to: Apicurio#2641

Signed-off-by: Andrew Borley <BORLEY@uk.ibm.com>
carlesarnal pushed a commit that referenced this issue Jul 27, 2022
- Kafka passes an empty, but non-null Headers object to the
Deserializer, which can cause an NPE when the headersHandler
has not been initialized (which occurs when the
`apicurio.registry.headers.enabled` property is set to
false).

Contributes to: #2641

Signed-off-by: Andrew Borley <BORLEY@uk.ibm.com>
@carlesarnal carlesarnal linked a pull request Jul 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants