You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tarun4201 (via GitHub)" <gi...@apache.org> on 2026/10/12 14:18:21 UTC

Re: [I] [MNG-7594] ComparableVersion#getCanonical() returns incorrect results for zero between hyphens [maven]

Tarun4201 commented on issue #8873:
URL: https://github.com/apache/maven/issues/8873#issuecomment-6126118907

   ### [MNG-7594] Fix ComparableVersion getCanonical for zero between hyphens
   
   #### Summary
   Resolves the issue where version strings like `1-0-1` had contradictory canonicalization and comparison results. Previously, `ListItem.normalize()` removed intermediate zero elements before child lists, resulting in `1-0-1` being canonicalized to `1-1` while still sorting as `1-0-1 < 1-1`.
   
   #### Changes
   1. **`ListItem.normalize()`**:
      - Added safe pattern matching and non-empty guards when inspecting following `ListItem` entries before determining if preceding null/zero items can be pruned.
   2. **Regression Tests (`ComparableVersionTest#testMng7594`)**:
      - Verified that `1-0-1` canonicalizes to `1-0-1` and compares equal to `1--1`.
      - Verified `1-0-1 < 1-1` and `canonical("1-0-1") != canonical("1-1")`.
      - Covered related zero-between-hyphen cases (e.g. `1-0-2 < 1-0.1 < 1-2` from MNG-6420, multiple hyphenated zeros `1-0-0-1`, and normalized trailing zeros like `1-0-1-0 == 1-0-1`).
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org