Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6964

Maven version sorting is internally inconsistent

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.6.3
    • Fix Version/s: 3.8.2, 4.0.0, 4.0.0-alpha-1
    • Component/s: Core
    • Labels:
      None

      Description

      There's a bug where version sorting is inconsistent. This manifests like this:

      $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.alpha 1
      Display parameters as parsed by Maven (in canonical form) and comparison result:
      1. 1-0.alpha == 1-0.alpha
         1-0.alpha == 1
      2. 1 == 1
      
      $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.beta 1
      Display parameters as parsed by Maven (in canonical form) and comparison result:
      1. 1-0.beta == 1-0.beta
         1-0.beta == 1
      2. 1 == 1
      
      $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.beta 1-0.alpha
      Display parameters as parsed by Maven (in canonical form) and comparison result:
      1. 1-0.beta == 1-0.beta
         1-0.beta > 1-0.alpha
      2. 1-0.alpha == 1-0.alpha
      

      Thus there is no correct total order: 1-0.beta > 1.0.alpha even though both 1-0.beta and 1-0.alpha are equal to 1.

      I think this is likely due to a logical bug where any dot-separated segments following a zero or release (ga or final) is simply truncated in certain circumstances:

      $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.x 1-0
      Display parameters as parsed by Maven (in canonical form) and comparison result:
      1. 1-0.x == 1-0.x
         1-0.x == 1-0
      2. 1-0 == 1
      

      but

      $ java -jar ~/local/apache-maven/lib/maven-artifact-3.6.3.jar 1-0.x-1 1-0-1
      Display parameters as parsed by Maven (in canonical form) and comparison result:
      1. 1-0.x-1 == 1-0.x-1
         1-0.x-1 > 1-0-1
      2. 1-0-1 == 1-1
      

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              dennisl Dennis Lundberg
              Reporter:
              dmlloyd David M. Lloyd

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment