Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5208

ModuleUtil compareVersions should sort a SNAPSHOT version as "less than"

    XMLWordPrintable

Details

    • Bug
    • Status: Ready for Work
    • Should
    • Resolution: Unresolved
    • None
    • None
    • None
    • Low

    Description

      That is:

      1.8.4-SNAPSHOT < 1.8.4

      This doesn't appear to be happening... the comparator strips off the "-SNAPSHOT" qualifier, but then ignores it entirely.

      This is relevant because when loading modules, if it finds multiple modules with the same ID it chooses the "most recent" one and deletes the others from the file system.

      So, for example, if you have the following two modules in your modules directory:

      somemodule-1.8.4-SNAPSHOT
      somemodule-1.8.4

      "somemodule-1.8.4-SNAPSHOT" will be started, and "somemodule-1.8.4" will be removed, when really you'd want to keep "somemodule-1.8.4" as it is the most recent version.

      To reproduce, you can take the existing test:

      	@Test
      	@Verifies(value = "treat SNAPSHOT as earliest version", method = "compareVersion(String,String)")
      	public void compareVersion_shouldTreatSNAPSHOTAsEarliestVersion() throws Exception {
      		String olderVersion = "1.8.3";
      		String newerVersion = "1.8.4-SNAPSHOT";
      		Assert.assertTrue(ModuleUtil.compareVersion(newerVersion, olderVersion) > 0);
      		//should still return the correct value if the arguments are switched
      		Assert.assertTrue(ModuleUtil.compareVersion(olderVersion, newerVersion) < 0);
      	}
      

      and set the older version to "1.8.4-SNAPSHOT" and the newer version to "1.8.4".

      Gliffy Diagrams

        Attachments

          Activity

            People

              musakizito Kizito Musa
              mogoodrich Mark Goodrich
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 1 day
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified