pjfanning commented on code in PR #3532:
URL: https://github.com/apache/pekko/pull/3532#discussion_r3955511948
##########
actor/src/main/scala/org/apache/pekko/io/dns/internal/ResolvConfParser.scala:
##########
@@ -33,7 +33,10 @@ private[dns] object ResolvConfParser {
*/
def parseFile(file: File): Try[ResolvConf] = {
Try {
- parseLines(Files.lines(file.toPath).iterator().asScala)
+ // the stream holds the file open until closed, and parseLines consumes
it eagerly
+ val lines = Files.lines(file.toPath)
+ try parseLines(lines.iterator().asScala)
+ finally lines.close()
Review Comment:
The current code base prefers Java try with resources probably because Scala
Using is not supported directly by Scala 2.12. If we want to start using Scala
Using, I think we should have a general PR to do that across existing call
sites. Apparently, it is pretty efficient and shouldn't be significantly
different performance wise to try with resources.
--
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]