fix: marshaling stack overflow in noncurrentversion lifecycle config (#10971)

This commit is contained in:
Poorna Krishnamoorthy 2020-11-24 20:43:11 -08:00 committed by GitHub
parent 3ad41fe89d
commit 7742238495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -189,6 +189,12 @@ func TestMarshalLifecycleConfig(t *testing.T) {
Filter: Filter{Prefix: "prefix-1"},
Expiration: Expiration{Date: ExpirationDate(midnightTS)},
},
{
Status: "Enabled",
Filter: Filter{Prefix: "prefix-1"},
Expiration: Expiration{Date: ExpirationDate(midnightTS)},
NoncurrentVersionTransition: NoncurrentVersionTransition{NoncurrentDays: 2, StorageClass: "TEST"},
},
},
}
b, err := xml.MarshalIndent(&lc, "", "\t")

View File

@ -52,7 +52,8 @@ func (n NoncurrentVersionTransition) MarshalXML(e *xml.Encoder, start xml.StartE
if n.NoncurrentDays == ExpirationDays(0) {
return nil
}
return e.EncodeElement(&n, start)
type noncurrentVersionTransitionWrapper NoncurrentVersionTransition
return e.EncodeElement(noncurrentVersionTransitionWrapper(n), start)
}
// IsDaysNull returns true if days field is null