Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop on cloudwatchlogs GetLogEventsPages #1908

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion aws/request/request_pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Pagination struct {
NewRequest func() (*Request, error)

started bool
prevTokens []interface{}
nextTokens []interface{}

err error
Expand All @@ -49,7 +50,7 @@ type Pagination struct {
//
// Will always return true if Next has not been called yet.
func (p *Pagination) HasNextPage() bool {
return !(p.started && len(p.nextTokens) == 0)
return !(p.started && (len(p.nextTokens) == 0 || awsutil.DeepEqual(p.nextTokens, p.prevTokens)))
}

// Err returns the error Pagination encountered when retrieving the next page.
Expand Down Expand Up @@ -96,6 +97,7 @@ func (p *Pagination) Next() bool {
return false
}

p.prevTokens = p.nextTokens
p.nextTokens = req.nextPageTokens()
p.curPage = req.Data

Expand Down
5 changes: 5 additions & 0 deletions aws/request/request_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@ func TestPagination_Standalone(t *testing.T) {
testCase{aws.String("SecondValue"), aws.String("FirstToken"), aws.String("SecondToken")},
testCase{aws.String("ThirdValue"), aws.String("SecondToken"), aws.String("")},
},
{
testCase{aws.String("FirstValue"), aws.String("InitalToken"), aws.String("FirstToken")},
testCase{aws.String("SecondValue"), aws.String("FirstToken"), aws.String("SecondToken")},
testCase{nil, aws.String("SecondToken"), aws.String("SecondToken")},
},
}

for _, c := range cases {
Expand Down
4 changes: 2 additions & 2 deletions service/s3/s3manager/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestBatchDeleteList(t *testing.T) {
Key: aws.String("1"),
},
},
NextMarker: aws.String("marker"),
NextMarker: aws.String("1stMarker"),
IsTruncated: aws.Bool(true),
},
{
Expand All @@ -477,7 +477,7 @@ func TestBatchDeleteList(t *testing.T) {
Key: aws.String("2"),
},
},
NextMarker: aws.String("marker"),
NextMarker: aws.String("2ndMarker"),
IsTruncated: aws.Bool(true),
},
{
Expand Down