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

This commit is contained in:
gabry.wu 2020-03-14 19:22:24 +08:00 committed by GitHub
parent e0389aebf6
commit 61ebbf2946
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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