Skip to content

Commit

Permalink
Fix grpc test vet warning (coredns#3341)
Browse files Browse the repository at this point in the history
This fixes the vet warning: the cancel function returned by
context.WithTimeout should be called, not discarded, to avoid a context
leak.

Signed-off-by: Ingo Gottwald <in.gottwald@gmail.com>
  • Loading branch information
gottwald authored and miekg committed Oct 1, 2019
1 parent 575cea4 commit fa6718d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ func TestGrpc(t *testing.T) {
}
defer g.Stop()

ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
conn, err := grpc.DialContext(ctx, tcp, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
t.Fatalf("Expected no error but got: %s", err)
Expand Down

0 comments on commit fa6718d

Please sign in to comment.