Browse Source

Adapting partial code(file name start with L) to the sonar cloud rule (#2171)

pull/3/MERGE
gabry.wu 5 years ago committed by gaojun2048
parent
commit
7f7f50a828
  1. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/interceptor/LoginHandlerInterceptor.java
  2. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
  3. 21
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/log/LoggerRequestProcessor.java
  4. 8
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/log/LogClientService.java

11
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 {
}
}

2
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);

21
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 "";
}

8
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);

Loading…
Cancel
Save