Skip to content

Commit 73a95d6

Browse files
johscheuerbrownleej
authored andcommitted
Check for nil before casting
1 parent 20b6930 commit 73a95d6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

controllers/lock_client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ func (client *RealLockClient) TakeLock() (bool, error) {
7373
hasLock, err := client.database.Transact(func(transaction fdb.Transaction) (interface{}, error) {
7474
return client.takeLockInTransaction(transaction)
7575
})
76+
77+
if hasLock == nil {
78+
return false, err
79+
}
80+
7681
return hasLock.(bool), err
7782
}
7883

@@ -129,6 +134,7 @@ func (client *RealLockClient) takeLockInTransaction(transaction fdb.Transaction)
129134
client.updateLock(transaction, startTime)
130135
return true, nil
131136
}
137+
132138
log.Info("Failed to get lock", "namespace", cluster.Namespace, "cluster", cluster.Name, "owner", ownerID, "startTime", time.Unix(startTime, 0), "endTime", time.Unix(endTime, 0))
133139
return false, nil
134140
}

0 commit comments

Comments
 (0)