[GitHub] [incubator-dolphinscheduler] dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause.
dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause. URL: https://github.com/apache/incubator-dolphinscheduler/pull/1716#discussion_r363068718 ## File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/FourLetterWordMain.java ## @@ -59,23 +59,22 @@ public static String send4LetterWord(String host, int port, String cmd) */ public static String send4LetterWord(String host, int port, String cmd, int timeout) throws IOException { -LOG.info("connecting to " + host + " " + port); -Socket sock = new Socket(); +LOG.info("connecting to {0} {1}", host, port); InetSocketAddress hostaddress= host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(InetAddress.getByName(null), port); -BufferedReader reader = null; -try { + +try (Socket sock = new Socket(); + OutputStream outstream = sock.getOutputStream(); + BufferedReader reader = +new BufferedReader( +new InputStreamReader(sock.getInputStream( { sock.setSoTimeout(timeout); sock.connect(hostaddress, timeout); -OutputStream outstream = sock.getOutputStream(); outstream.write(cmd.getBytes()); outstream.flush(); // this replicates NC - close the output stream before reading Review comment: +1 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-dolphinscheduler] dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause.
dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause. URL: https://github.com/apache/incubator-dolphinscheduler/pull/1716#discussion_r363068716 ## File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/FourLetterWordMain.java ## @@ -59,23 +59,22 @@ public static String send4LetterWord(String host, int port, String cmd) */ public static String send4LetterWord(String host, int port, String cmd, int timeout) throws IOException { -LOG.info("connecting to " + host + " " + port); -Socket sock = new Socket(); +LOG.info("connecting to {0} {1}", host, port); Review comment: +1 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [incubator-dolphinscheduler] dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause.
dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause. URL: https://github.com/apache/incubator-dolphinscheduler/pull/1716#discussion_r363068712 ## File path: dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java ## @@ -446,6 +452,6 @@ public void printReplacedSql(String content, String formatSql,String rgex, Map
[GitHub] [incubator-dolphinscheduler] dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause.
dailidong commented on a change in pull request #1716: Fix bug: Use try-with-resources or close this "Socket" in a "finally" clause. URL: https://github.com/apache/incubator-dolphinscheduler/pull/1716#discussion_r363067539 ## File path: dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java ## @@ -101,7 +101,7 @@ public void handle() throws Exception { // set the name of the current thread String threadLoggerInfoName = String.format(Constants.TASK_LOG_INFO_FORMAT, taskProps.getTaskAppId()); Thread.currentThread().setName(threadLoggerInfoName); -logger.info(sqlParameters.toString()); +logger.info("{}", sqlParameters); Review comment: +1 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services