dcapwell commented on code in PR #65:
URL: https://github.com/apache/cassandra-accord/pull/65#discussion_r1408562427


##########
accord-core/src/test/java/accord/impl/basic/Cluster.java:
##########
@@ -496,7 +506,7 @@ private Function<List<Id>, BiFunction<Id, Id, Link>> 
overrideLinks(RandomSource
                 case RANDOM_BIDIRECTIONAL:
                 case RANDOM_UNIDIRECTIONAL:
                     boolean bidirectional = kind == RANDOM_BIDIRECTIONAL;
-                    int count = random.nextInt(bidirectional || 
random.nextBoolean() ? nodesList.size() : (nodesList.size() * 
nodesList.size())/2);
+                    int count = random.nextInt(bidirectional || 
random.nextBoolean() ? nodesList.size() : Math.max(1, (nodesList.size() * 
nodesList.size())/2));

Review Comment:
   when nodesList size = 1, this fails (`1/2 = 0), hence the `Math.max(1` to 
keep it safe



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to