mirror of https://github.com/apache/maven.git
[MNG-6964] Maven version sorting is internally inconsistent.
This commit is contained in:
parent
a9f337fd63
commit
ce27f0ec61
|
@ -530,8 +530,16 @@ public class ComparableVersion
|
||||||
{
|
{
|
||||||
return 0; // 1-0 = 1- (normalize) = 1
|
return 0; // 1-0 = 1- (normalize) = 1
|
||||||
}
|
}
|
||||||
Item first = get( 0 );
|
// Compare the entire list of items with null - not just the first one, MNG-6964
|
||||||
return first.compareTo( null );
|
for ( Item i : this )
|
||||||
|
{
|
||||||
|
int result = i.compareTo( null );
|
||||||
|
if ( result != 0 )
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
switch ( item.getType() )
|
switch ( item.getType() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,6 +295,21 @@ public class ComparableVersionTest
|
||||||
checkVersionsArrayEqual( arr );
|
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 < 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()
|
public void testLocaleIndependent()
|
||||||
{
|
{
|
||||||
Locale orig = Locale.getDefault();
|
Locale orig = Locale.getDefault();
|
||||||
|
|
Loading…
Reference in New Issue