@@ -121,11 +121,16 @@ void Consumer::unsubscribe() {
121121}
122122
123123void Consumer::assign (const TopicPartitionList& topic_partitions) {
124- TopicPartitionsListPtr topic_list_handle = convert (topic_partitions);
125- // If the list is empty, then we need to use a null pointer
126- auto handle = topic_partitions.empty () ? nullptr : topic_list_handle.get ();
127- rd_kafka_resp_err_t error = rd_kafka_assign (get_handle (), handle);
128- check_error (error);
124+ rd_kafka_resp_err_t error;
125+ if (topic_partitions.empty ()) {
126+ error = rd_kafka_assign (get_handle (), nullptr );
127+ check_error (error);
128+ }
129+ else {
130+ TopicPartitionsListPtr topic_list_handle = convert (topic_partitions);
131+ error = rd_kafka_assign (get_handle (), topic_list_handle.get ());
132+ check_error (error, topic_list_handle.get ());
133+ }
129134}
130135
131136void Consumer::unassign () {
@@ -181,15 +186,15 @@ Consumer::get_offsets_committed(const TopicPartitionList& topic_partitions) cons
181186 TopicPartitionsListPtr topic_list_handle = convert (topic_partitions);
182187 rd_kafka_resp_err_t error = rd_kafka_committed (get_handle (), topic_list_handle.get (),
183188 static_cast <int >(get_timeout ().count ()));
184- check_error (error);
189+ check_error (error, topic_list_handle. get () );
185190 return convert (topic_list_handle);
186191}
187192
188193TopicPartitionList
189194Consumer::get_offsets_position (const TopicPartitionList& topic_partitions) const {
190195 TopicPartitionsListPtr topic_list_handle = convert (topic_partitions);
191196 rd_kafka_resp_err_t error = rd_kafka_position (get_handle (), topic_list_handle.get ());
192- check_error (error);
197+ check_error (error, topic_list_handle. get () );
193198 return convert (topic_list_handle);
194199}
195200
@@ -287,10 +292,15 @@ void Consumer::commit(const Message& msg, bool async) {
287292
288293void Consumer::commit (const TopicPartitionList* topic_partitions, bool async) {
289294 rd_kafka_resp_err_t error;
290- error = rd_kafka_commit (get_handle (),
291- !topic_partitions ? nullptr : convert (*topic_partitions).get (),
292- async ? 1 : 0 );
293- check_error (error);
295+ if (topic_partitions == nullptr ) {
296+ error = rd_kafka_commit (get_handle (), nullptr , async ? 1 : 0 );
297+ check_error (error);
298+ }
299+ else {
300+ TopicPartitionsListPtr topic_list_handle = convert (*topic_partitions);
301+ error = rd_kafka_commit (get_handle (), topic_list_handle.get (), async ? 1 : 0 );
302+ check_error (error, topic_list_handle.get ());
303+ }
294304}
295305
296306void Consumer::handle_rebalance (rd_kafka_resp_err_t error,
0 commit comments