pjfanning commented on code in PR #402:
URL: https://github.com/apache/incubator-pekko/pull/402#discussion_r1231952800


##########
actor/src/main/scala/org/apache/pekko/io/dns/IdGenerator.scala:
##########
@@ -57,5 +59,5 @@ private[pekko] object IdGenerator {
    * @return a random sequence of ids for production
    */
   def random(rand: java.util.Random): IdGenerator =
-    () => (rand.nextInt(MaxUnsignedShort) - Short.MinValue).toShort
+    () => (rand.nextInt(SignedShortBound) + Short.MinValue).toShort

Review Comment:
   0 is valid. so `rand.nextInt(65536) will give us a response int between 0 
and 65535 - ie 65536 possible answers. This is what I'm looking for.
   
   65535 + Short.MIN_VALUE (-32768) is 32767 (which is Short.MAX_VALUE).
   
   0 + Short.MIN_VALUE is -32768 (Short.MIN_VALUE).



-- 
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