未验证 提交 8085e931 编写于 作者: G gabry.wu 提交者: GitHub

Adapting partial code(file name start with Q) to the sonar cloud rule (#2242)

上级 ca6872a9
...@@ -20,6 +20,7 @@ import org.apache.dolphinscheduler.api.enums.Status; ...@@ -20,6 +20,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.dao.entity.Queue; import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.QueueMapper; import org.apache.dolphinscheduler.dao.mapper.QueueMapper;
...@@ -43,7 +44,7 @@ import java.util.Map; ...@@ -43,7 +44,7 @@ import java.util.Map;
@Service @Service
public class QueueService extends BaseService { public class QueueService extends BaseService {
private static final Logger logger = LoggerFactory.getLogger(TenantService.class); private static final Logger logger = LoggerFactory.getLogger(QueueService.class);
@Autowired @Autowired
private QueueMapper queueMapper; private QueueMapper queueMapper;
...@@ -186,19 +187,16 @@ public class QueueService extends BaseService { ...@@ -186,19 +187,16 @@ public class QueueService extends BaseService {
} }
// check queue name is exist // check queue name is exist
if (!queueName.equals(queueObj.getQueueName())) { if (!queueName.equals(queueObj.getQueueName())
if (checkQueueNameExist(queueName)) { && checkQueueNameExist(queueName)) {
putMsg(result, Status.QUEUE_NAME_EXIST, queueName); putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
return result; return result;
}
} }
// check queue value is exist // check queue value is exist
if (!queue.equals(queueObj.getQueue())) { if (!queue.equals(queueObj.getQueue()) && checkQueueExist(queue)) {
if (checkQueueExist(queue)) { putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
putMsg(result, Status.QUEUE_VALUE_EXIST, queue); return result;
return result;
}
} }
// check old queue using by any user // check old queue using by any user
...@@ -267,7 +265,7 @@ public class QueueService extends BaseService { ...@@ -267,7 +265,7 @@ public class QueueService extends BaseService {
* @return true if the queue not exists, otherwise return false * @return true if the queue not exists, otherwise return false
*/ */
private boolean checkQueueExist(String queue) { private boolean checkQueueExist(String queue) {
return queueMapper.queryAllQueueList(queue, null).size() > 0; return CollectionUtils.isNotEmpty(queueMapper.queryAllQueueList(queue, null));
} }
/** /**
...@@ -278,7 +276,7 @@ public class QueueService extends BaseService { ...@@ -278,7 +276,7 @@ public class QueueService extends BaseService {
* @return true if the queue name not exists, otherwise return false * @return true if the queue name not exists, otherwise return false
*/ */
private boolean checkQueueNameExist(String queueName) { private boolean checkQueueNameExist(String queueName) {
return queueMapper.queryAllQueueList(null, queueName).size() > 0; return CollectionUtils.isNotEmpty(queueMapper.queryAllQueueList(null, queueName));
} }
/** /**
...@@ -290,7 +288,7 @@ public class QueueService extends BaseService { ...@@ -290,7 +288,7 @@ public class QueueService extends BaseService {
* @return true if need to update user * @return true if need to update user
*/ */
private boolean checkIfQueueIsInUsing (String oldQueue, String newQueue) { private boolean checkIfQueueIsInUsing (String oldQueue, String newQueue) {
return !oldQueue.equals(newQueue) && userMapper.queryUserListByQueue(oldQueue).size() > 0; return !oldQueue.equals(newQueue) && CollectionUtils.isNotEmpty(userMapper.queryUserListByQueue(oldQueue));
} }
} }
...@@ -64,7 +64,7 @@ public class QueueMapperTest { ...@@ -64,7 +64,7 @@ public class QueueMapperTest {
queue.setCreateTime(new Date()); queue.setCreateTime(new Date());
//update //update
int update = queueMapper.updateById(queue); int update = queueMapper.updateById(queue);
Assert.assertEquals(update, 1); Assert.assertEquals(1, update);
queueMapper.deleteById(queue.getId()); queueMapper.deleteById(queue.getId());
} }
...@@ -75,7 +75,7 @@ public class QueueMapperTest { ...@@ -75,7 +75,7 @@ public class QueueMapperTest {
public void testDelete(){ public void testDelete(){
Queue queue = insertOne(); Queue queue = insertOne();
int delete = queueMapper.deleteById(queue.getId()); int delete = queueMapper.deleteById(queue.getId());
Assert.assertEquals(delete, 1); Assert.assertEquals(1, delete);
} }
/** /**
......
...@@ -70,9 +70,10 @@ public class QuartzExecutors { ...@@ -70,9 +70,10 @@ public class QuartzExecutors {
synchronized (QuartzExecutors.class) { synchronized (QuartzExecutors.class) {
// when more than two threads run into the first null check same time, to avoid instanced more than one time, it needs to be checked again. // when more than two threads run into the first null check same time, to avoid instanced more than one time, it needs to be checked again.
if (INSTANCE == null) { if (INSTANCE == null) {
INSTANCE = new QuartzExecutors(); QuartzExecutors quartzExecutors = new QuartzExecutors();
//finish QuartzExecutors init //finish QuartzExecutors init
INSTANCE.init(); quartzExecutors.init();
INSTANCE = quartzExecutors;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册