He-Pin commented on code in PR #371:
URL: https://github.com/apache/incubator-pekko/pull/371#discussion_r1224213414


##########
actor/src/main/scala/org/apache/pekko/io/dns/internal/AsyncDnsResolver.scala:
##########
@@ -85,12 +85,15 @@ private[io] final class AsyncDnsResolver(
     settings.SearchDomains,
     settings.NDots)
 
-  private var requestId: Short = 0
+  private val shortSupplier = new UniqueRandomShortProvider()
+  // Since ShortSupplier has lazy initialization lets immediately
+  // call nextId to warm it up so that next time its actually needed
+  // it will be fast
+  shortSupplier.nextId()
 
-  private def nextId(): Short = {
-    requestId = (requestId + 1).toShort
-    requestId
-  }
+  // DNS id's need to be random, see 
https://datatracker.ietf.org/doc/html/rfc5452#section-4.3.
+  private def nextId(): Short =
+    shortSupplier.nextId()

Review Comment:
   Do not need to start a new line.



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