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 WithLatests() fixup on duplicate keys #3281

Merged
merged 1 commit into from
Jul 25, 2018
Merged

Conversation

bboreham
Copy link
Collaborator

The fixup() method was modifying a copy of its input, so you could get duplicate keys in the output.

Thankfully this is rare: in most cases WithLatests() is called with fields that are not duplicates of existing ones.

Added a test that would have caught it.

I made this PR against the release-1.9 branch so we can make a clean patch release.

if m[i-1].key == m[i].key {
if m[i-1].Timestamp.Before(m[i].Timestamp) {
m = append(m[:i-1], m[i:]...)
func (m *StringLatestMap) fixup() {

This comment was marked as abuse.

This comment was marked as abuse.

The fixup() method was modifying a copy of its input, so you could get
duplicate keys in the output. Change it to return the new slice.

Thankfully this is rare: in most cases WithLatests() is called with
fields that are not duplicates of existing ones.
@bboreham bboreham merged commit e8b3c13 into release-1.9 Jul 25, 2018
@bboreham bboreham deleted the fix-withlatest branch September 13, 2019 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants