Skip to content

Commit

Permalink
Fix listGroups segfault when passing an undefined matchConsumerGroupS…
Browse files Browse the repository at this point in the history
…tates (#85)
  • Loading branch information
emasab authored Sep 16, 2024
1 parent d014984 commit 8b6521c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,15 @@ NAN_METHOD(AdminClient::NodeListGroups) {
Nan::New("matchConsumerGroupStates").ToLocalChecked();
bool is_match_states_set =
Nan::Has(config, match_consumer_group_states_key).FromMaybe(false);
v8::Local<v8::Array> match_states_array;
v8::Local<v8::Array> match_states_array = Nan::New<v8::Array>();

if (is_match_states_set) {
match_states_array = GetParameter<v8::Local<v8::Array>>(
config, "matchConsumerGroupStates", match_states_array);
match_states = Conversion::Admin::FromV8GroupStateArray(match_states_array);
if (match_states_array->Length()) {
match_states = Conversion::Admin::FromV8GroupStateArray(
match_states_array);
}
}

// Queue the work.
Expand Down
4 changes: 3 additions & 1 deletion test/promisified/admin/list_groups.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ describe('Admin > listGroups', () => {
await waitFor(() => consumer.assignment().length > 0, () => null, 1000);

await admin.connect();
let listGroupsResult = await admin.listGroups();
let listGroupsResult = await admin.listGroups({
matchConsumerGroupStates: undefined,
});
expect(listGroupsResult.errors).toEqual([]);
expect(listGroupsResult.groups).toEqual(
expect.arrayContaining([
Expand Down

0 comments on commit 8b6521c

Please sign in to comment.