Skip to content

Commit

Permalink
kv: Allow nil when checking for empty lease.
Browse files Browse the repository at this point in the history
Treat nil lease as empty when checking for empty lease.
Recent changes in #66374
as well as in #74315 changed
how lease is stored as well as modified receiver type.  As a result,
attempts to print empty `EvictionToken{}` will result in a nil panic.

Release Notes: None
  • Loading branch information
Yevgeniy Miretskiy committed Jan 6, 2022
1 parent 68e805a commit a5787e8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/roachpb/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ func (l *Lease) SafeFormat(w redact.SafePrinter, _ rune) {

// Empty returns true for the Lease zero-value.
func (l *Lease) Empty() bool {
return *l == (Lease{})
return l == nil || *l == (Lease{})
}

// OwnedBy returns whether the given store is the lease owner.
Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func TestLeaseString(t *testing.T) {
},
{
lease: nil,
expected: "<nil>",
expected: "<empty>",
},
{
lease: &roachpb.Lease{
Expand Down

0 comments on commit a5787e8

Please sign in to comment.