-
Notifications
You must be signed in to change notification settings - Fork 1.6k
KafkaTemplate receive(Collection<TopicPartitionOffset> requested, Duration pollTimeout) can have nulls #2240
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
Comments
I think this is correct observation. Would you mind to contribute the fix: https://github.com/spring-projects/spring-kafka/blob/main/CONTRIBUTING.adoc ? Thanks |
Sure. I can look into this. What should be the expected behaviour when The doc on KafkaOperations states
So maybe it should throw a KafkaException if tpo.getOffset() is null |
I think a null (or negative) offset should throw an exception; a null return should be skipped from the list - still return an entry for the TP, but with an empty list (if that's the result) - assuming |
- Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
- Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
- Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
Fixes spring-projectsGH-2240 (spring-projects#2240) - Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
Fixes spring-projectsGH-2240 (spring-projects#2240) - Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
Fixes spring-projectsGH-2240 (spring-projects#2240) - Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
Fixes spring-projectsGH-2240 (spring-projects#2240) - Ensures that we dont get ConsumerRecords with nulls in the list - Ensures that we do not allow null offsets
Uh oh!
There was an error while loading. Please reload this page.
In what version(s) of Spring for Apache Kafka are you seeing this issue?
This is on main branch
Describe the bug
KafkaTemplate has a method:
This method correctly states that the return value could be null via @nullable and the javadoc also states the same.
However there is another method:
This method returns a ConsumerRecords object however the ConsumerRecord itself could be null. Therefore you end up with a collection with null inside it.
To Reproduce
I reproduced it by calling
receive(Collection<TopicPartitionOffset> requested, Duration pollTimeout)
on a brand new topic that was empty. The javadoc doesn't mention the elements could be null.Could we do a null check before add the ConsumerRecord to the ConsumerRecords object?
Furthermore
tpo.getOffset()
can also return null which leads to an auto unboxing issue.The text was updated successfully, but these errors were encountered: