-
Notifications
You must be signed in to change notification settings - Fork 28
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: correctly deserialize consecutive XML flat maps #879
Conversation
04ab28e
to
0cc29b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems right to me. Do we have similar problems in our other deserializers (e.g., JSON)?
val compareTo = when (descriptor.hasTrait<Flattened>()) { | ||
// Prefer seeking to XmlSerialName if the trait exists | ||
true -> when (descriptor.hasTrait<XmlSerialName>()) { | ||
true -> descriptor.expectTrait<XmlSerialName>().name | ||
false -> mapTrait.key | ||
} | ||
false -> mapTrait.entry | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: I generally find when
/true
/false
to be less readable than if
/else
or null-coalescing. In this case, when (descriptor.hasTrait<XmlSerialName>()) { ... }
can be replaced with:
descriptor.findTrait<XmlSerialName>()?.name ?: mapTrait.key
Thankfully JSON doesn't have this problem because it only has one way to represent a map |
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
* feat: identity API upstream changes (#864) * track upstream codegen changes (#879) * track upstream IdentityProvider and Attributes changes (#881) * add base class for credentials config (#883) BREAKING CHANGE: `CredentialsProvider` method name and signature changed. `signer` property removed from service client config in favor of `authSchemes` override.
This PR fixes a bug in the XML deserializer which fails to process consecutive flat maps properly. Before this change, the deserializer would seek forward until it found a matching map key. Consecutive flat maps sharing the same key names would be lumped together unintentionally.
The fix is to seek using
XmlSerialName
as a comparator since this is the only thing distinguishing different flat maps. A new deserialize methodpeekSeek
is added which seeks forward and only consumes tokens if they are a match.Issue #
awslabs/aws-sdk-kotlin#962
Description of changes
This fixes a bug when deserializing consecutive flat maps. See the new "consecutive flat maps" test case for an example of an XML tree for which parsing previously failed.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.