Skip to content

Commit

Permalink
Fix null pointer exception in sigterm
Browse files Browse the repository at this point in the history
Right now if you try to consumer some messages as a part of a group
consumer and then decide to <Ctrl-C> the app you will get an NPE
  • Loading branch information
konart committed Jan 15, 2024
1 parent c032438 commit b0d5db0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/consume/GroupConsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ func (handler *groupHandler) ConsumeClaim(session sarama.ConsumerGroupSession, c

for {
select {
case message := <-messageChannel:
if message != nil {
handler.messages <- message
case message, ok := <-messageChannel:
if !ok {
output.Debugf("consume claim via channel interrupted")
handler.cancel()
return nil
}
handler.messages <- message
session.MarkMessage(message, "")
case <-handler.stopConsumers:
output.Debugf("stop consume claim via channel")
Expand Down

0 comments on commit b0d5db0

Please sign in to comment.