Skip to content

Commit

Permalink
[FIXED] Panic on ConsumerInfo when empty reponse and errors are retur…
Browse files Browse the repository at this point in the history
…ned (#1426)

Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio authored Oct 3, 2023
1 parent 9e5e706 commit ff131ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jetstream/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func (p *pullConsumer) Info(ctx context.Context) (*ConsumerInfo, error) {
}
return nil, resp.Error
}
if resp.Error == nil && resp.ConsumerInfo == nil {
return nil, ErrConsumerNotFound
}

p.info = resp.ConsumerInfo
return resp.ConsumerInfo, nil
Expand Down Expand Up @@ -188,6 +191,9 @@ func getConsumer(ctx context.Context, js *jetStream, stream, name string) (Consu
}
return nil, resp.Error
}
if resp.Error == nil && resp.ConsumerInfo == nil {
return nil, ErrConsumerNotFound
}

cons := &pullConsumer{
jetStream: js,
Expand Down
3 changes: 3 additions & 0 deletions jetstream/ordered.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ func (c *orderedConsumer) Info(ctx context.Context) (*ConsumerInfo, error) {
}
return nil, resp.Error
}
if resp.Error == nil && resp.ConsumerInfo == nil {
return nil, ErrConsumerNotFound
}

c.currentConsumer.info = resp.ConsumerInfo
return resp.ConsumerInfo, nil
Expand Down
3 changes: 3 additions & 0 deletions js.go
Original file line number Diff line number Diff line change
Expand Up @@ -3223,6 +3223,9 @@ func (js *js) getConsumerInfoContext(ctx context.Context, stream, consumer strin
}
return nil, info.Error
}
if info.Error == nil && info.ConsumerInfo == nil {
return nil, ErrConsumerNotFound
}
return info.ConsumerInfo, nil
}

Expand Down

0 comments on commit ff131ad

Please sign in to comment.