fix(inputs.amqp_consumer): Fix panic on Stop() if not connected successfully (#12817)

This commit is contained in:
Sven Rebhan 2023-03-09 15:20:53 +01:00 committed by GitHub
parent 603cdfb620
commit e58891be11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -439,6 +439,10 @@ func (a *AMQPConsumer) onDelivery(track telegraf.DeliveryInfo) bool {
}
func (a *AMQPConsumer) Stop() {
// We did not connect successfully so there is nothing to do here.
if a.conn == nil || a.conn.IsClosed() {
return
}
a.cancel()
a.wg.Wait()
err := a.conn.Close()