Skip to content

Commit

Permalink
fix: context timeout not launched on get bucket location #1413 (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcocia authored Nov 23, 2020
1 parent 6914cb6 commit 26addf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bucket-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c Client) getBucketLocation(ctx context.Context, bucketName string) (strin
}

// Initialize a new request.
req, err := c.getBucketLocationRequest(bucketName)
req, err := c.getBucketLocationRequest(ctx, bucketName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -169,7 +169,7 @@ func processBucketLocationResponse(resp *http.Response, bucketName string) (buck
}

// getBucketLocationRequest - Wrapper creates a new getBucketLocation request.
func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, error) {
func (c Client) getBucketLocationRequest(ctx context.Context, bucketName string) (*http.Request, error) {
// Set location query.
urlValues := make(url.Values)
urlValues.Set("location", "")
Expand Down Expand Up @@ -198,7 +198,7 @@ func (c Client) getBucketLocationRequest(bucketName string) (*http.Request, erro
}

// Get a new HTTP request for the method.
req, err := http.NewRequest(http.MethodGet, urlStr, nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, urlStr, nil)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion bucket-cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package minio

import (
"bytes"
"context"
"encoding/xml"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -236,7 +237,7 @@ func TestGetBucketLocationRequest(t *testing.T) {
}
}

actualReq, err := client.getBucketLocationRequest(testCase.bucketName)
actualReq, err := client.getBucketLocationRequest(context.Background(), testCase.bucketName)
if err != nil && testCase.shouldPass {
t.Errorf("Test %d: Expected to pass, but failed with: <ERROR> %s", i+1, err.Error())
}
Expand Down

0 comments on commit 26addf2

Please sign in to comment.