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 <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]