You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/04/12 14:15:47 UTC

[GitHub] [servicecomb-service-center] little-cui commented on a change in pull request #939: fix mongo listwatch panic problem

little-cui commented on a change in pull request #939:
URL: https://github.com/apache/servicecomb-service-center/pull/939#discussion_r611668081



##########
File path: datasource/mongo/sd/listwatch_inner.go
##########
@@ -132,19 +138,23 @@ func (lw *mongoListWatch) doParseDocumentToResource(fullDocument bson.Raw) (reso
 			log.Error("error to parse bson raw to documentInfo", err)
 			return
 		}
-		resource.Key = instance.Instance.InstanceId
-		resource.Value = instance
-		resource.Index = instance.Instance.ServiceId
+		if instance.Instance != nil {

Review comment:
       如果为nil是什么原因,是否要增加日志

##########
File path: datasource/mongo/client/errortypes.go
##########
@@ -17,22 +17,23 @@ package client
 
 import (
 	"go.mongodb.org/mongo-driver/mongo"
+	"strings"
 )
 
 const (
-	DuplicateKey      = 11000
+	DuplicateKey      = "E11000"
 	CollectionsExists = 48
 )
 
 func IsDuplicateKey(err error) bool {
+	return strings.Contains(err.Error(),DuplicateKey)

Review comment:
       没有go fmt




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