elharo opened a new pull request, #179:
URL: https://github.com/apache/maven-toolchains-plugin/pull/179
## Summary
Fixes #166
The `version()` comparator in `ToolchainDiscoverer` used
`String.compareTo()` for version segment comparison, which produces incorrect
ordering for versions with different digit counts (e.g. "8" was sorted before
"11" because '8' > '1' lexicographically).
## Changes
- **ToolchainDiscoverer.java**: Replace lexicographic `String.compareTo()`
with numeric comparison of the leading digit prefix in each dot-separated
version segment. A non-throwing character scan extracts digits (avoids
`NumberFormatException` overhead). Segments with non-numeric suffixes (e.g.
`11-ea`, `1.8.0_202`, `17.0.2+8`) are compared by leading digit prefix first;
if equal, the segment without a suffix is treated as greater (release >
pre-release).
- **ToolchainDiscovererTest.java**: 5 tests covering:
- Simple single-number versions (8, 11, 17)
- Multi-part versions (11.0.1 vs 11.0.31 vs 17.0.1 vs 1.8)
- Multi-digit segments (17.0.2 vs 17.0.10)
- Non-numeric underscore suffixes (1.8.0_202 vs 1.8.0_121)
- EA/pre-release suffixes (11-ea vs 11)
## Testing
All 5 version comparator tests pass. The pre-existing `testDiscovery` test
is environment-dependent and unrelated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]