Skip to content

Commit f81b2dc

Browse files
authored
Update CI to include Go 1.19 (#4500)
Fixes issue with Go 1.19 discovered in the S3 transfer manager's windows upload and downloader buffer pools. It looks like the update to Go 1.19 changes the code path that is used by the pool because io.NopCloser was updated to forward WriterTo if the underlying Writer implemented it. Looks likes we'd made some assumptions about this behavior not being present. This PR suppresses the WriterTo of the buffer pool to prevent the unexpected usage.
1 parent 45d5208 commit f81b2dc

File tree

5 files changed

+78
-57
lines changed

5 files changed

+78
-57
lines changed

.github/workflows/go.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
1818
go-version:
19-
- 1.16.x
20-
- 1.17.x
2119
- 1.18.x
20+
- 1.19.x
2221
steps:
2322
- name: Setup Go
2423
uses: actions/setup-go@v2
@@ -32,12 +31,9 @@ jobs:
3231

3332
- name: Test
3433
shell: bash
35-
run: |
36-
if [ "${{ matrix.os }}" == "windows-latest" ]; then
37-
make unit-no-verify
38-
else
39-
make get-deps-verify ci-test
40-
fi
34+
# SDK is currently being released with go 1.18, this cannot perform
35+
# ci-tests task until the release system is updated to go 1.19.
36+
run: make unit-no-verify
4137

4238
deprecated-go-module-tests:
4339
needs: full-test
@@ -52,6 +48,8 @@ jobs:
5248
- 1.13.x
5349
- 1.14.x
5450
- 1.15.x
51+
- 1.16.x
52+
- 1.17.x
5553
steps:
5654
- name: Setup Go
5755
uses: actions/setup-go@v2
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM golang:1.19
2+
3+
ENV GOPROXY=direct
4+
5+
ADD . /go/src/github.com/aws/aws-sdk-go
6+
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
vim \
9+
&& rm -rf /var/list/apt/lists/*
10+
11+
WORKDIR /go/src/github.com/aws/aws-sdk-go
12+
CMD ["make", "get-deps-verify", "unit"]

private/model/api/example_test.go

+47-48
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package api
66
import (
77
"encoding/json"
88
"testing"
9+
10+
"github.com/aws/aws-sdk-go/private/util"
911
)
1012

1113
func buildAPI() *API {
@@ -238,80 +240,77 @@ func TestExampleGeneration(t *testing.T) {
238240
def.API = a
239241

240242
def.setup()
241-
expected := `
242-
import (
243+
expected := `import (
244+
"bytes"
243245
"fmt"
244-
"strings"
245246
"time"
246247
247-
"` + SDKImportRoot + `/aws"
248-
"` + SDKImportRoot + `/aws/awserr"
249-
"` + SDKImportRoot + `/aws/session"
250-
"` + SDKImportRoot + `/service/fooservice"
251-
248+
"github.com/aws/aws-sdk-go/aws"
249+
"github.com/aws/aws-sdk-go/aws/session"
250+
"github.com/aws/aws-sdk-go/service/fooservice"
252251
)
253252
254253
var _ time.Duration
255-
var _ strings.Reader
256-
var _ aws.Config
254+
var _ bytes.Buffer
257255
258-
func parseTime(layout, value string) *time.Time {
259-
t, err := time.Parse(layout, value)
260-
if err != nil {
261-
panic(err)
262-
}
263-
return &t
264-
}
256+
func ExampleFooService_Foo() {
257+
sess := session.Must(session.NewSession())
265258
266-
// I pity the foo
267-
//
268-
// Foo bar baz qux
269-
func ExampleFooService_Foo_shared00() {
270-
svc := fooservice.New(session.New())
271-
input := &fooservice.FooInput{
272-
BarShape: aws.String("Hello world"),
259+
svc := fooservice.New(sess)
260+
261+
params := &fooservice.FooInput{
262+
BarShape: aws.String("string"),
273263
ComplexField: &fooservice.ComplexShape{
274-
Field: aws.String("bar"),
264+
Field: aws.String("string"),
275265
List: []*fooservice.NestedComplexShape{
276-
{
277-
NestedField: aws.String("qux"),
266+
&fooservice.NestedComplexShape{ // Required
267+
NestedField: aws.String("string"),
278268
},
269+
// More values...
279270
},
280271
},
281272
ListField: []*fooservice.ComplexShape{
282-
{
283-
Field: aws.String("baz"),
273+
&fooservice.ComplexShape{ // Required
274+
Field: aws.String("string"),
275+
List: []*fooservice.NestedComplexShape{
276+
&fooservice.NestedComplexShape{ // Required
277+
NestedField: aws.String("string"),
278+
},
279+
// More values...
280+
},
284281
},
282+
// More values...
285283
},
286284
ListsField: [][]*fooservice.ComplexShape{
287-
{
288-
{
289-
Field: aws.String("baz"),
285+
[]*fooservice.ComplexShape{ // Required
286+
&fooservice.ComplexShape{ // Required
287+
Field: aws.String("string"),
288+
List: []*fooservice.NestedComplexShape{
289+
&fooservice.NestedComplexShape{ // Required
290+
NestedField: aws.String("string"),
291+
},
292+
// More values...
293+
},
290294
},
295+
// More values...
291296
},
297+
// More values...
292298
},
293299
}
300+
resp, err := svc.Foo(params)
294301
295-
result, err := svc.Foo(input)
296302
if err != nil {
297-
if aerr, ok := err.(awserr.Error); ok {
298-
switch aerr.Code() {
299-
default:
300-
fmt.Println(aerr.Error())
301-
}
302-
} else {
303-
// Print the error, cast err to awserr.Error to get the Code and
304-
// Message from an error.
305-
fmt.Println(err.Error())
306-
}
303+
// Print the error, cast err to awserr.Error to get the Code and
304+
// Message from an error.
305+
fmt.Println(err.Error())
307306
return
308307
}
309308
310-
fmt.Println(result)
311-
}
312-
`
313-
if expected != a.ExamplesGoCode() {
314-
t.Errorf("Expected:\n%s\nReceived:\n%s\n", expected, a.ExamplesGoCode())
309+
// Pretty-print the response data.
310+
fmt.Println(resp)
311+
}`
312+
if e, a := util.GoFmt(expected), util.GoFmt(a.ExampleGoCode()); e != a {
313+
t.Errorf("Expect:\n%s\nActual:\n%s\n", e, a)
315314
}
316315
}
317316

service/s3/s3manager/download.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,11 @@ func (d *downloader) tryDownloadChunk(in *s3.GetObjectInput, w io.Writer) (int64
464464
}
465465
d.setTotalBytes(resp) // Set total if not yet set.
466466

467-
n, err := io.Copy(w, resp.Body)
467+
var src io.Reader = resp.Body
468+
if d.cfg.BufferProvider != nil {
469+
src = &suppressWriterAt{suppressed: src}
470+
}
471+
n, err := io.Copy(w, src)
468472
resp.Body.Close()
469473
if err != nil {
470474
return n, &errReadingBody{err: err}

service/s3/s3manager/writer_read_from.go

+8
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ func (p *PooledBufferedReadFromProvider) GetReadFrom(writer io.Writer) (r Writer
7373
}
7474
return r, cleanup
7575
}
76+
77+
type suppressWriterAt struct {
78+
suppressed io.Reader
79+
}
80+
81+
func (s *suppressWriterAt) Read(p []byte) (n int, err error) {
82+
return s.suppressed.Read(p)
83+
}

0 commit comments

Comments
 (0)