You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by as...@apache.org on 2019/02/03 02:42:36 UTC
[incubator-druid] branch master updated: Try-with-resources should
be used since the new syntax is more readable. (#6944)
This is an automated email from the ASF dual-hosted git repository.
asdf2014 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-druid.git
The following commit(s) were added to refs/heads/master by this push:
new 61f165c Try-with-resources should be used since the new syntax is more readable. (#6944)
61f165c is described below
commit 61f165c23f33381f2ea05ae61feeef6a940ec0f0
Author: Furkan KAMACI <fu...@gmail.com>
AuthorDate: Sun Feb 3 05:42:28 2019 +0300
Try-with-resources should be used since the new syntax is more readable. (#6944)
* Try-with-resources should be used since the new syntax is more readable.
* Fixed checkstyle error.
---
.../java/org/apache/druid/common/utils/SocketUtil.java | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/core/src/main/java/org/apache/druid/common/utils/SocketUtil.java b/core/src/main/java/org/apache/druid/common/utils/SocketUtil.java
index c02351d..8eb3877 100644
--- a/core/src/main/java/org/apache/druid/common/utils/SocketUtil.java
+++ b/core/src/main/java/org/apache/druid/common/utils/SocketUtil.java
@@ -41,24 +41,12 @@ public class SocketUtil
int currPort = startPort;
while (currPort < 0xffff) {
- ServerSocket socket = null;
- try {
- socket = new ServerSocket(currPort);
+ try (ServerSocket socket = new ServerSocket(currPort)) {
return currPort;
}
catch (IOException e) {
++currPort;
}
- finally {
- if (socket != null) {
- try {
- socket.close();
- }
- catch (IOException e) {
-
- }
- }
- }
}
throw new ISE("Unable to find open port between [%d] and [%d]", startPort, currPort);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org