You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by li...@apache.org on 2020/03/14 11:22:31 UTC

[incubator-dolphinscheduler] branch dev updated: Adapting partial code(file name start with L) to the sonar cloud rule (#2171)

This is an automated email from the ASF dual-hosted git repository.

lidongdai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 61ebbf2  Adapting partial code(file name start with L) to the sonar cloud rule (#2171)
61ebbf2 is described below

commit 61ebbf29463809449734ff00b00e6d9627170d10
Author: gabry.wu <wu...@qq.com>
AuthorDate: Sat Mar 14 19:22:24 2020 +0800

    Adapting partial code(file name start with L) to the sonar cloud rule (#2171)
---
 .../api/interceptor/LoginHandlerInterceptor.java    | 11 -----------
 .../dolphinscheduler/common/utils/LoggerUtils.java  |  2 +-
 .../server/log/LoggerRequestProcessor.java          | 21 +++++----------------
 .../service/log/LogClientService.java               |  8 ++++----
 4 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
index 380eea5..98bac42 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
@@ -27,7 +27,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.servlet.HandlerInterceptor;
-import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -90,14 +89,4 @@ public class LoginHandlerInterceptor implements HandlerInterceptor {
     return true;
   }
 
-  @Override
-  public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
-
-  }
-
-  @Override
-  public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
-
-  }
-
 }
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
index fc08eb6..191df33 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
@@ -79,7 +79,7 @@ public class LoggerUtils {
      */
     public static List<String> getAppIds(String log, Logger logger) {
 
-        List<String> appIds = new ArrayList<String>();
+        List<String> appIds = new ArrayList<>();
 
         Matcher matcher = APPLICATION_REGEX.matcher(log);
 
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java
index 4e4404e..4b21d5f 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java
@@ -17,6 +17,7 @@
 package org.apache.dolphinscheduler.server.log;
 
 import io.netty.channel.Channel;
+import org.apache.dolphinscheduler.common.utils.IOUtils;
 import org.apache.dolphinscheduler.remote.command.Command;
 import org.apache.dolphinscheduler.remote.command.CommandType;
 import org.apache.dolphinscheduler.remote.command.log.*;
@@ -116,16 +117,8 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
         }catch (IOException e){
             logger.error("get file bytes error",e);
         }finally {
-            if (bos != null){
-                try {
-                    bos.close();
-                } catch (IOException ignore) {}
-            }
-            if (in != null){
-                try {
-                    in.close();
-                } catch (IOException ignore) {}
-            }
+            IOUtils.closeQuietly(bos);
+            IOUtils.closeQuietly(in);
         }
         return new byte[0];
     }
@@ -146,7 +139,7 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
         } catch (IOException e) {
             logger.error("read file error",e);
         }
-        return Collections.EMPTY_LIST;
+        return Collections.emptyList();
     }
 
     /**
@@ -168,11 +161,7 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
         }catch (IOException e){
             logger.error("read file error",e);
         }finally {
-            try {
-                if (br != null){
-                    br.close();
-                }
-            } catch (IOException ignore) {}
+            IOUtils.closeQuietly(br);
         }
         return "";
     }
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java
index 01a4991..163cd36 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java
@@ -40,7 +40,7 @@ public class LogClientService {
     /**
      *  request time out
      */
-    private final long logRequestTimeout = 10 * 1000;
+    private static final long LOG_REQUEST_TIMEOUT = 10 * 1000L;
 
     /**
      * construct client
@@ -75,7 +75,7 @@ public class LogClientService {
         final Address address = new Address(host, port);
         try {
             Command command = request.convert2Command();
-            Command response = this.client.sendSync(address, command, logRequestTimeout);
+            Command response = this.client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
             if(response != null){
                 RollViewLogResponseCommand rollReviewLog = FastJsonSerializer.deserialize(
                         response.getBody(), RollViewLogResponseCommand.class);
@@ -103,7 +103,7 @@ public class LogClientService {
         final Address address = new Address(host, port);
         try {
             Command command = request.convert2Command();
-            Command response = this.client.sendSync(address, command, logRequestTimeout);
+            Command response = this.client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
             if(response != null){
                 ViewLogResponseCommand viewLog = FastJsonSerializer.deserialize(
                         response.getBody(), ViewLogResponseCommand.class);
@@ -131,7 +131,7 @@ public class LogClientService {
         final Address address = new Address(host, port);
         try {
             Command command = request.convert2Command();
-            Command response = this.client.sendSync(address, command, logRequestTimeout);
+            Command response = this.client.sendSync(address, command, LOG_REQUEST_TIMEOUT);
             if(response != null){
                 GetLogBytesResponseCommand getLog = FastJsonSerializer.deserialize(
                         response.getBody(), GetLogBytesResponseCommand.class);