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

[GitHub] [incubator-inlong] charlely commented on a change in pull request #586: [INLONG-788]Fix Go SDK Remote Cache Bug

charlely commented on a change in pull request #586:
URL: https://github.com/apache/incubator-inlong/pull/586#discussion_r675342041



##########
File path: tubemq-client-twins/tubemq-client-go/remote/remote.go
##########
@@ -449,14 +445,20 @@ func (r *RmtDataCache) ReleasePartition(checkDelay bool, filterConsume bool, con
 }
 
 func (r *RmtDataCache) removeFromIndexPartitions(partitionKey string) {
-	pos := 0
+	pos := -1
 	for i, p := range r.indexPartitions {
 		if p == partitionKey {
 			pos = i
 			break
 		}
 	}
-	r.indexPartitions = append(r.indexPartitions[:pos], r.indexPartitions[pos+1:]...)
+	if len(r.indexPartitions) == 1 && pos == 0 {
+		r.indexPartitions = []string{}
+		return
+	}
+	if pos >= 0 {
+		r.indexPartitions = append(r.indexPartitions[:pos], r.indexPartitions[pos+1:]...)

Review comment:
       Need check pos is Last.
   if len(r.indexPartitions) == 1 && pos == 0 {
      r.indexPartitions = nil  // Because always use append to add item.
   }
   if pos >= 0 {
   ....
   }




-- 
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@inlong.apache.org

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