Closed akolybelnikov closed 2 years ago
The actual method includes the following:
if strings.Contains(info.FullMethodName, "Produce") || len(p.followers) == 0 {
result.SubConn = p.leader
} else if strings.Contains(info.FullMethodName, "Consume") {
result.SubConn = p.nextFollower()
}
I have entirely missed the else-if statement. I need to chill...
If
len(p.followers) == 0
in Pick it attempts to assign a next follower to the result.SubConn, but thenextFollower
throws an integer divide by zero runtime error because in Go% 0
is division by zero. The error is detectable if you runTestPickerNoSubConnAvailable
.I am checking for the length and returning
nil
early, but checkingif strings.Contains(info.FullMethodName, "Produce") || len(p.followers) == 0
loses its meaning inPick
.