Skip to content

Commit

Permalink
Index duplicate verification failure.
Browse files Browse the repository at this point in the history
Lets try to duplicate property value holder instead of reference it twice.
  • Loading branch information
MishaDemianenko committed Apr 20, 2017
1 parent ebf65a8 commit a776166
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -401,19 +401,29 @@ else if ( data.size() == 1 )
} }
else else
{ {
int duplicateIndex = (int) randomLongInRange( 0, data.size() ); int duplicateIndex = randomIntInRange( 0, data.size() );
int duplicateValueIndex; int duplicateValueIndex;
do do
{ {
duplicateValueIndex = ThreadLocalRandom.current().nextInt( data.size() ); duplicateValueIndex = ThreadLocalRandom.current().nextInt( data.size() );
} }
while ( duplicateValueIndex == duplicateIndex ); while ( duplicateValueIndex == duplicateIndex );
PropertyValue duplicateValue = data.get( duplicateValueIndex ); PropertyValue duplicate = duplicatePropertyValue( data.get( duplicateValueIndex ) );
data.set( duplicateIndex, duplicateValue ); data.set( duplicateIndex, duplicate );
} }
return data; return data;
} }


private static PropertyValue duplicatePropertyValue( PropertyValue propertyValue )
{
return new PropertyValue( propertyValue.value );
}

private static int randomIntInRange( int min, int max )
{
return ThreadLocalRandom.current().nextInt( min, max );
}

private static long randomLongInRange( long min, long max ) private static long randomLongInRange( long min, long max )
{ {
return ThreadLocalRandom.current().nextLong( min, max ); return ThreadLocalRandom.current().nextLong( min, max );
Expand Down

0 comments on commit a776166

Please sign in to comment.