Skip to content

VerboseJavaScopeSelector.ScopeComparator is inconsistent for scopes outside the ordered list #136

Description

@elharo

Summary

VerboseJavaScopeSelector.ScopeComparator orders scopes by indexOf in the fixed list ["compile", "runtime", "provided", "test"]. Any scope not in that list (e.g. system, or a custom scope) returns indexOf == -1 for both operands, so the comparator returns 0 for such pairs and can select the wrong “max” scope. This violates the Comparator contract and can corrupt the REDUCED_SCOPE value recorded on the winning node.

Affected code

src/main/java/org/apache/maven/shared/dependency/graph/internal/VerboseJavaScopeSelector.java:50-57

Suggested fix

Give unknown scopes a deterministic ordering (e.g. treat as lower/least, or fall back to the full known Java scope list including system), and add a test for scopes outside the four listed ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions