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

master
Poorna Krishnamoorthy 4 years ago committed by GitHub
parent 3ad41fe89d
commit 7742238495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/bucket/lifecycle/lifecycle_test.go
  2. 3
      pkg/bucket/lifecycle/noncurrentversion.go

@ -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")

@ -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

Loading…
Cancel
Save