[MNG-6964] Maven version sorting is internally inconsistent.

This commit is contained in:
Dennis Lundberg 2020-07-22 11:24:26 +02:00
parent 51c0399030
commit 4f193b3fc2
2 changed files with 25 additions and 2 deletions

View File

@ -530,8 +530,16 @@ public int compareTo( Item item )
{
return 0; // 1-0 = 1- (normalize) = 1
}
Item first = get( 0 );
return first.compareTo( null );
// Compare the entire list of items with null - not just the first one, MNG-6964
for ( Item i : this )
{
int result = i.compareTo( null );
if ( result != 0 )
{
return result;
}
}
return 0;
}
switch ( item.getType() )
{

View File

@ -295,6 +295,21 @@ public void testVersionZeroEqualWithLeadingZeroes()
checkVersionsArrayEqual( arr );
}
/**
* Test <a href="https://issues.apache.org/jira/browse/MNG-6964">MNG-6964</a> edge cases
* for qualifiers that start with "-0.", which was showing A == C and B == C but A &lt; B.
*/
public void testMng6964()
{
String a = "1-0.alpha";
String b = "1-0.beta";
String c = "1";
checkVersionsOrder( a, c ); // Now a < c, but before MNG-6964 they were equal
checkVersionsOrder( b, c ); // Now b < c, but before MNG-6964 they were equal
checkVersionsOrder( a, b ); // Should still be true
}
public void testLocaleIndependent()
{
Locale orig = Locale.getDefault();