You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "BewareMyPower (via GitHub)" <gi...@apache.org> on 2023/03/08 10:29:35 UTC
[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #973: fix: prevent rpc client panic on rpc response if `ProducerReady` is nil
BewareMyPower commented on code in PR #973:
URL: https://github.com/apache/pulsar-client-go/pull/973#discussion_r1129233311
##########
pulsar/internal/connection.go:
##########
@@ -523,7 +523,7 @@ func (c *connection) internalReceivedCommand(cmd *pb.BaseCommand, headersAndPayl
c.handleResponse(cmd.Success.GetRequestId(), cmd)
case pb.BaseCommand_PRODUCER_SUCCESS:
- if !*cmd.ProducerSuccess.ProducerReady {
+ if !cmd.ProducerSuccess.GetProducerReady() {
request, ok := c.findPendingRequest(cmd.ProducerSuccess.GetRequestId())
if ok {
Review Comment:
When `cmd.ProducerSuccess.ProducerReady` is `nil`, it means the response is from broker < 2.8.0, in this case, `handleResponse` is not called, so the pending `Produce` request will never be deleted.
We should differ the case when `ProducerReady` is `nil` and `ProducerReady` is `false`:
- `nil`: call `handleResponse`
- `false`: trigger the callback directly
```go
case pb.BaseCommand_PRODUCER_SUCCESS:
resp := cmd.ProducerSuccess
if resp.ProducerReady == nil || *resp.ProducerReady {
c.handleResponse(cmd.ProducerSuccess.GetRequestId(), cmd)
} else {
request, ok := c.findPendingRequest(cmd.ProducerSuccess.GetRequestId())
if ok {
request.callback(cmd, nil)
}
}
```
/cc @shibd
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org