Skip to content

Commit

Permalink
Create empty topic partition list for callback if needed
Browse files Browse the repository at this point in the history
We've seen a case where the offsets pointer in the commit callback was
null. Check for this state and pass an empty topic partiton list into
the callback if it happens.
  • Loading branch information
thijsc committed Nov 25, 2021
1 parent f41af6c commit 85f2a78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/consumer/base_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ pub(crate) unsafe extern "C" fn native_commit_cb<C: ConsumerContext>(
} else {
Ok(())
};
let tpl = TopicPartitionList::from_ptr(offsets);
let tpl = if offsets.is_null() {
TopicPartitionList::new()
} else {
TopicPartitionList::from_ptr(offsets)
};
context.commit_callback(commit_error, &tpl);

mem::forget(tpl); // Do not free offsets
Expand Down

0 comments on commit 85f2a78

Please sign in to comment.