brharrington commented on code in PR #401:
URL: https://github.com/apache/incubator-pekko/pull/401#discussion_r1231609526
##########
actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala:
##########
@@ -54,7 +56,6 @@ private[pekko] object IdGenerator {
/**
* @return a random sequence of ids for production
*/
- def random(rand: java.util.Random): IdGenerator = new IdGenerator {
- override def nextId(): Short = rand.nextInt(Short.MaxValue).toShort
- }
+ def random(rand: java.util.Random): IdGenerator =
+ () => (rand.nextInt(MaxUnsignedShort) - Short.MinValue).toShort
Review Comment:
Since `Short.MinValue` is negative should this be `+ Short.MinValue`? I'm
assuming the intent is to move the value into the permitted range for a short
before casting. That said I don't think it will alter the behavior as it will
overflow and use negative values when cast to short anyway.
--
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]