gianm commented on a change in pull request #6944: Try-with-resources should be 
used since the new syntax is more readable.
URL: https://github.com/apache/incubator-druid/pull/6944#discussion_r252303413
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/common/utils/SocketUtil.java
 ##########
 @@ -41,24 +41,11 @@ public static int findOpenPortFrom(int startPort)
     int currPort = startPort;
 
     while (currPort < 0xffff) {
-      ServerSocket socket = null;
-      try {
-        socket = new ServerSocket(currPort);
+      try (ServerSocket socket = new ServerSocket(currPort)) {
 
 Review comment:
   The behavior is a bit different. IOExceptions on `socket.close()` used to be 
suppressed, but now they'll be thrown. I think that's okay, since we don't 
expect to get exceptions when closing the socket, but just wanted to point it 
out.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to