Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-30694

Sorting Maven components with Version returns unpredictable order in some cases

    Details

    • Story Points:
      3
    • Release Note:
      Yes
    • Notability:
      2
    • InvestmentLayer:
      support-escalated
    • Aha Concept:
      non-concept

      Description

      SYMPTOM:

      Sorting components with the Version column in web UI or REST API does not look like sorting with the alphabetical order. It looks like almost random.

      REPRODUCE STEPS:

      1. Install NXRM 3.37.0
      2. mvn deploy with the following versions:
        "7.10.0" "7.9.0" "SortTest-1.3.1" "SortTest-1.3.0" "SortTest-1.2.0" "SortTest-1.1.0" "SortTest-1.0.6" "SortTest-1.0.5" "SortTest-1.0.4" "SortTest-1.0.3" "SortTest-1.0.2" "SortTest.SR1" "SortTest"
        
      1. Login to the web UI and go to Browse => Maven, and search your uploaded components by typing the Group Id and Artifact Id, then click "Version" column to sort the list ascending order:

        Users wouldn't be able to figure out what kind of order was used in above "Version" Ascending order.

      EXPECTED:

      It should sort with alpha-numeric order.

      POTENTIAL CAUSE:

      NEXUS-28918 introduced new sorting order which looks like populating the "normalized_version" field.
      I'm suspecting the "normalized_version" values for "SortTest-x.y.z" may become same so that the list shown in UI becomes unpredictable order:

      String[] strs = {"7.10.0","7.9.0","VersionTest-1.3.1","VersionTest-1.3.0","VersionTest-1.2.0",
       "VersionTest-1.1.0","VersionTest-1.0.6","VersionTest-1.0.5","VersionTest-1.0.4","VersionTest-1.0.3",
       "VersionTest-1.0.2","VersionTest.SR1","VersionTest"};
      
      for(int i = 0; i< strs.length; i++){
          System.out.println(strs[i] + " " + versionNormalizer.getNormalizedValue(strs[i]));
      }
      

      Running above returns below:

      7.10.0 000000007.000000010.000000000.c
      7.9.0 000000007.000000009.000000000.c
      VersionTest-1.3.1 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.3.0 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.2.0 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.1.0 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.0.6 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.0.5 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.0.4 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.0.3 .000000000.000000000.e.versiontest-000000001
      VersionTest-1.0.2 .000000000.000000000.e.versiontest-000000001
      VersionTest.SR1 .000000000.000000000.e.sr-000000001
      VersionTest .000000000.000000000.e.versiontest
      

      This would be because the "splitQualifier" expects the version string should be "x.y.z-<Qualifier>" (like below), so that this returns "" (empty string) for the "version".

      jshell> versionNormalizer.getNormalizedValue("1.3.1-VersionTest");
      $15 ==> "000000001.000000003.000000001.e.versiontest"
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              hosako Hajime Osako
              CC:
              Bharat
              Last Updated By:
              Nicholas Blair Nicholas Blair
              Team:
              NXRM - IMMORTALS
              Votes:
              9 Vote for this issue
              Watchers:
              23 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title