You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/06/08 00:15:55 UTC

[GitHub] [pulsar-client-go] freeznet opened a new pull request #536: fix nil pointer error with `GetPartitionedTopicMetadata`

freeznet opened a new pull request #536:
URL: https://github.com/apache/pulsar-client-go/pull/536


   ### Motivation
   
   ```
   panic: runtime error: invalid memory address or nil pointer dereference
   [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xc7bd24]
   goroutine 129 [running]:
   github.com/apache/pulsar-client-go/pulsar/internal.(*lookupService).GetPartitionedTopicMetadata(0xc00017ac80, 0xc00040c1e0, 0x2c, 0x0, 0x0, 0x5)
   	/go/pkg/mod/github.com/apache/pulsar-client-go@v0.4.1-0.20210504220432-203f2f60325b/pulsar/internal/lookup_service.go:193 +0x244
   github.com/apache/pulsar-client-go/pulsar.(*client).TopicPartitions(0xc00010f860, 0xc00040c1e0, 0x2c, 0xc0005e6f80, 0x2, 0x2, 0xc0005e6f7c, 0x2)
   	/go/pkg/mod/github.com/apache/pulsar-client-go@v0.4.1-0.20210504220432-203f2f60325b/pulsar/client_impl.go:184 +0xa2
   github.com/apache/pulsar-client-go/pulsar.(*consumer).internalTopicSubscribeToPartitions(0xc0001d01a0, 0x0, 0x0)
   	/go/pkg/mod/github.com/apache/pulsar-client-go@v0.4.1-0.20210504220432-203f2f60325b/pulsar/consumer_impl.go:250 +0x74
   github.com/apache/pulsar-client-go/pulsar.(*consumer).runBackgroundPartitionDiscovery.func1(0xc0001280b0, 0xc00015c540, 0xc00017a190, 0xc0001d01a0)
   	/go/pkg/mod/github.com/apache/pulsar-client-go@v0.4.1-0.20210504220432-203f2f60325b/pulsar/consumer_impl.go:237 +0xce
   created by github.com/apache/pulsar-client-go/pulsar.(*consumer).runBackgroundPartitionDiscovery
   	/go/pkg/mod/github.com/apache/pulsar-client-go@v0.4.1-0.20210504220432-203f2f60325b/pulsar/consumer_impl.go:229 +0xcd
   ```
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] cckellogg commented on a change in pull request #536: fix nil pointer error with `GetPartitionedTopicMetadata`

Posted by GitBox <gi...@apache.org>.
cckellogg commented on a change in pull request #536:
URL: https://github.com/apache/pulsar-client-go/pull/536#discussion_r647585697



##########
File path: pulsar/internal/lookup_service.go
##########
@@ -190,11 +190,23 @@ func (ls *lookupService) GetPartitionedTopicMetadata(topic string) (*Partitioned
 	}
 	ls.log.Debugf("Got topic{%s} partitioned metadata response: %+v", topic, res)
 
-	if res.Response.PartitionMetadataResponse.Error != nil {
-		return nil, errors.New(res.Response.PartitionMetadataResponse.GetError().String())
+	var partitionedTopicMetadata PartitionedTopicMetadata
+
+	if res.Response.Error != nil {
+		return nil, errors.New(res.Response.GetError().String())
+	}
+
+	if res.Response.PartitionMetadataResponse != nil {
+		if res.Response.PartitionMetadataResponse.Error != nil {
+			return nil, errors.New(res.Response.PartitionMetadataResponse.GetError().String())
+		}
+
+		partitionedTopicMetadata.Partitions = int(res.Response.PartitionMetadataResponse.GetPartitions())
+	} else {
+		return nil, fmt.Errorf("get topic{%s} partitioned metadata failed", topic)

Review comment:
       maybe add more context here like `no partitioned metadata for topic{%s} in lookup response`




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] merlimat merged pull request #536: fix nil pointer error with `GetPartitionedTopicMetadata`

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #536:
URL: https://github.com/apache/pulsar-client-go/pull/536


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] freeznet commented on pull request #536: fix nil pointer error with `GetPartitionedTopicMetadata`

Posted by GitBox <gi...@apache.org>.
freeznet commented on pull request #536:
URL: https://github.com/apache/pulsar-client-go/pull/536#issuecomment-856356739


   /pulsarbot run-failure-checks


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org