From d8d8e05e78b0d02e0d2ccb224b2873c4d859da21 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Mon, 31 Mar 2014 11:12:46 +0100 Subject: [PATCH 1/5] Disable debug mode in RDS package --- rds/rds.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rds/rds.go b/rds/rds.go index 543bdbc..f00b52c 100644 --- a/rds/rds.go +++ b/rds/rds.go @@ -8,7 +8,7 @@ import ( "strconv" ) -const debug = true +const debug = false const ( ServiceName = "rds" From c46dc2b042dd622ea292a61b74cb46530c66506d Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Mon, 31 Mar 2014 11:14:00 +0100 Subject: [PATCH 2/5] Update travis to run tests for all packages --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f3613b..b71954e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,15 @@ before_script: - FIXED=$(go fmt ./... | wc -l); if [ $FIXED -gt 0 ]; then echo "gofmt - $FIXED file(s) not formatted correctly, please run gofmt to fix this." && exit 1; fi script: + - go test -v ./autoscaling/ - go test -v ./aws/ + - go test -v ./cloudfront/ - go test -v ./cloudwatch/ - go test -v ./dynamodb/ - go test -v ./ec2/ - go test -v ./elb/ - go test -v ./iam/ + - go test -v ./rds/ + - go test -v ./route53/ - go test -v ./s3/ - go test -v ./sqs/ - - go test -v ./autoscaling/ - - go test -v ./rds/ From ab5ba6eb6a8d5c5409257477977ce1120643ad33 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Mon, 31 Mar 2014 14:07:46 +0100 Subject: [PATCH 3/5] Expand s3 nosuchbucket error test response --- s3/responses_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/s3/responses_test.go b/s3/responses_test.go index 7ceaba8..414ede0 100644 --- a/s3/responses_test.go +++ b/s3/responses_test.go @@ -2,9 +2,13 @@ package s3_test var GetObjectErrorDump = ` -NoSuchBucketThe specified bucket does not exist -non-existent-bucket3F1B667FAD71C3D8 -L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D + + NoSuchBucket + The specified bucket does not exist + non-existent-bucket + 3F1B667FAD71C3D8 + L4ee/zrm1irFXY5F45fKXIRdOf9ktsKY/8TDVawuMK2jWRb1RF84i1uBzkdNqS5D + ` var GetListResultDump1 = ` From 20a82206f1c078a994e43b4ce289bcfa1c96ac74 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Mon, 31 Mar 2014 14:55:24 +0100 Subject: [PATCH 4/5] S3: On non 20x response, defer closing until after building error Fixes problems caused by closing the response body, then passing this closed body to the XML unmarshaler in the error builder. This ignores returned errors, so the failure to marshal is silently ignored, and the error returned is a blank s3.Error --- s3/s3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3/s3.go b/s3/s3.go index 7689b1b..25a3b87 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -946,7 +946,7 @@ func (s3 *S3) run(req *request, resp interface{}) (*http.Response, error) { log.Printf("} -> %s\n", dump) } if hresp.StatusCode != 200 && hresp.StatusCode != 204 { - hresp.Body.Close() + defer hresp.Body.Close() return nil, buildError(hresp) } if resp != nil { From 51ed81fe9321576758499ff3b3f1c69f6125cd02 Mon Sep 17 00:00:00 2001 From: Matt Heath Date: Mon, 31 Mar 2014 14:56:21 +0100 Subject: [PATCH 5/5] S3: Correctly defer closing response body, unless nil --- s3/s3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/s3/s3.go b/s3/s3.go index 25a3b87..9831c35 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -168,11 +168,15 @@ func (b *Bucket) DelBucket() (err error) { // See http://goo.gl/isCO7 for details. func (b *Bucket) Get(path string) (data []byte, err error) { body, err := b.GetReader(path) + defer func() { + if body != nil { + body.Close() + } + }() if err != nil { return nil, err } data, err = ioutil.ReadAll(body) - body.Close() return data, err }