justxuewei commented on code in PR #2601:
URL: https://github.com/apache/dubbo-go/pull/2601#discussion_r1510529801


##########
cluster/cluster/failback/cluster_invoker.go:
##########
@@ -212,7 +206,7 @@ func newRetryTimerTask(loadbalance loadbalance.LoadBalance, 
invocation protocol.
                clusterInvoker: cInvoker,
        }
 
-       if retries, ok := invocation.GetAttachment(constant.RetriesKey); ok {
+       if retries, ok := invocation.GetAttachment(constant.RetriesKey); ok && 
retries != "" {
                rInt, _ := strconv.Atoi(retries)
                task.maxRetries = int64(rInt)

Review Comment:
   I am thinking that `retries != ""` couldn't cover all conditions, e.g. 
`retries` is an alphabetic character. Could we test in `strconv.Atoi`?
   
   ```suggestion
        if retries, ok := invocation.GetAttachment(constant.RetriesKey); ok {
                if rInt, ok := strconv.Atoi(retries); ok {
                    task.maxRetries = int64(rInt)
                }
   ```



##########
cluster/cluster/failover/cluster_invoker.go:
##########
@@ -104,17 +105,25 @@ func (invoker *failoverClusterInvoker) Invoke(ctx 
context.Context, invocation pr
        }
 }
 
-func getRetries(invokers []protocol.Invoker, methodName string) int {
+func getRetries(invokers []protocol.Invoker, invocation protocol.Invocation, 
methodName string) int {
        if len(invokers) <= 0 {
                return constant.DefaultRetriesInt
        }
        url := invokers[0].GetURL()
-
-       retries := url.GetMethodParamIntValue(methodName, constant.RetriesKey,
+       clientRetries := url.GetMethodParamIntValue(methodName, 
constant.RetriesKey,
                url.GetParamByIntValue(constant.RetriesKey, 
constant.DefaultRetriesInt))
+       retries := clientRetries
+       // Get CallOpt first
+       if callRetries, ok := invocation.GetAttachment(constant.RetriesKey); ok 
{
+               retries, _ = strconv.Atoi(callRetries)
+               if retries < 0 || callRetries == "" {
+                       retries = clientRetries
+               }

Review Comment:
   ```suggestion
                if retries, ok = strconv.Atoi(callRetries); !ok || retries < 0 {
                    retries = clientRetries
                 }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to