Skip to content

CollectionUtils.uniquify is incorrect in some cases #126883

@lkts

Description

@lkts

Elasticsearch Version

main

Installed Plugins

No response

Java Version

bundled

OS Version

--

Problem Description

CollectionUtils.uniquify(new ArrayList<>(List.of(1, 20, 20, 30, 30, 50)), Comparator.naturalOrder()) produces [1, 20, 30, 30, 50] but should produce [1, 20, 30, 50].

Steps to Reproduce

This test when added to CollectionUtilsTests fails.

    public void testUniquifyTwoRuns() {
        assertUniquify(List.of(1, 20, 20, 30, 30, 50), Comparator.naturalOrder(), 4);
    }

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions