Guard against a nil ServerDetails.Addr

It's not clear how or why this would ever be nil, but some of the unit tests produce a nil addr.  Be defensive.
This commit is contained in:
Sean Chittenden 2016-03-26 19:29:31 -07:00
parent ca5950a538
commit 970938c2dd
1 changed files with 5 additions and 1 deletions

View File

@ -35,10 +35,14 @@ type ServerDetails struct {
// Key returns the corresponding Key // Key returns the corresponding Key
func (s *ServerDetails) Key() *Key { func (s *ServerDetails) Key() *Key {
var serverAddr string
if s.Addr != nil {
serverAddr = s.Addr.String() + s.Addr.Network()
}
return &Key{ return &Key{
Datacenter: s.Datacenter, Datacenter: s.Datacenter,
Port: s.Port, Port: s.Port,
AddrString: s.Addr.String() + s.Addr.Network(), AddrString: serverAddr,
} }
} }