Skip to content

Commit 325040d

Browse files
elhimovoleg-jukovec
authored andcommitted
pool: use safe type assertion
1 parent f581fcd commit 325040d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pool/connection_pool.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,15 +1085,20 @@ func (p *ConnectionPool) getConnectionRole(conn *tarantool.Connection) (Role, er
10851085
return UnknownRole, ErrIncorrectResponse
10861086
}
10871087

1088-
instanceStatus, ok := data[0].(map[interface{}]interface{})["status"]
1088+
respFields, ok := data[0].(map[interface{}]interface{})
1089+
if !ok {
1090+
return UnknownRole, ErrIncorrectResponse
1091+
}
1092+
1093+
instanceStatus, ok := respFields["status"]
10891094
if !ok {
10901095
return UnknownRole, ErrIncorrectResponse
10911096
}
10921097
if instanceStatus != "running" {
10931098
return UnknownRole, ErrIncorrectStatus
10941099
}
10951100

1096-
replicaRole, ok := data[0].(map[interface{}]interface{})[roFieldName]
1101+
replicaRole, ok := respFields[roFieldName]
10971102
if !ok {
10981103
return UnknownRole, ErrIncorrectResponse
10991104
}

0 commit comments

Comments
 (0)