Skip to content

Commit

Permalink
GOCBC-824: Don't type assert nil pointer in ConnectionInfo
Browse files Browse the repository at this point in the history
Motivation
----------
When adding enhancements to timeout errors we introduced a possible
nil pointer where we can timeout a request before it's sent. This
would mean that there is no connection info on the request and so
the pointer is nil. We don't check for that so we panic.

Changes
-------
Add a nil check for request connInfo and if nil then return an
empty memdQRequestConnInfo.

Change-Id: I6c81c19dc6e810fa46db488794f2d96efe5f4e7e
Reviewed-on: http://review.couchbase.org/c/gocbcore/+/128089
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed May 14, 2020
1 parent dbfea6b commit 4656a57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion memdqpackets.go
Expand Up @@ -130,7 +130,11 @@ func (req *memdQRequest) Idempotent() bool {
}

func (req *memdQRequest) ConnectionInfo() memdQRequestConnInfo {
return req.connInfo.Load().(memdQRequestConnInfo)
p := req.connInfo.Load()
if p == nil {
return memdQRequestConnInfo{}
}
return p.(memdQRequestConnInfo)
}

func (req *memdQRequest) SetConnectionInfo(info memdQRequestConnInfo) {
Expand Down

0 comments on commit 4656a57

Please sign in to comment.