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/21 07:16:16 UTC
[incubator-dolphinscheduler] branch dev updated: Adapting partial
code(file name start with Q) to the sonar cloud rule (#2242)
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 8085e93 Adapting partial code(file name start with Q) to the sonar cloud rule (#2242)
8085e93 is described below
commit 8085e9310b6490dde3e7d1894a28326f3b157594
Author: gabry.wu <wu...@qq.com>
AuthorDate: Sat Mar 21 15:16:06 2020 +0800
Adapting partial code(file name start with Q) to the sonar cloud rule (#2242)
---
.../dolphinscheduler/api/service/QueueService.java | 26 ++++++++++------------
.../dao/mapper/QueueMapperTest.java | 4 ++--
.../service/quartz/QuartzExecutors.java | 5 +++--
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java
index 862c895..cba1b5f 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/QueueService.java
@@ -20,6 +20,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
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.User;
import org.apache.dolphinscheduler.dao.mapper.QueueMapper;
@@ -43,7 +44,7 @@ import java.util.Map;
@Service
public class QueueService extends BaseService {
- private static final Logger logger = LoggerFactory.getLogger(TenantService.class);
+ private static final Logger logger = LoggerFactory.getLogger(QueueService.class);
@Autowired
private QueueMapper queueMapper;
@@ -186,19 +187,16 @@ public class QueueService extends BaseService {
}
// check queue name is exist
- if (!queueName.equals(queueObj.getQueueName())) {
- if (checkQueueNameExist(queueName)) {
- putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
- return result;
- }
+ if (!queueName.equals(queueObj.getQueueName())
+ && checkQueueNameExist(queueName)) {
+ putMsg(result, Status.QUEUE_NAME_EXIST, queueName);
+ return result;
}
// check queue value is exist
- if (!queue.equals(queueObj.getQueue())) {
- if (checkQueueExist(queue)) {
- putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
- return result;
- }
+ if (!queue.equals(queueObj.getQueue()) && checkQueueExist(queue)) {
+ putMsg(result, Status.QUEUE_VALUE_EXIST, queue);
+ return result;
}
// check old queue using by any user
@@ -267,7 +265,7 @@ public class QueueService extends BaseService {
* @return true if the queue not exists, otherwise return false
*/
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 {
* @return true if the queue name not exists, otherwise return false
*/
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 {
* @return true if need to update user
*/
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));
}
}
diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java
index 30d2be0..ad3b05a 100644
--- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java
+++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/QueueMapperTest.java
@@ -64,7 +64,7 @@ public class QueueMapperTest {
queue.setCreateTime(new Date());
//update
int update = queueMapper.updateById(queue);
- Assert.assertEquals(update, 1);
+ Assert.assertEquals(1, update);
queueMapper.deleteById(queue.getId());
}
@@ -75,7 +75,7 @@ public class QueueMapperTest {
public void testDelete(){
Queue queue = insertOne();
int delete = queueMapper.deleteById(queue.getId());
- Assert.assertEquals(delete, 1);
+ Assert.assertEquals(1, delete);
}
/**
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java
index 60cdb1d..30e7c52 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/quartz/QuartzExecutors.java
@@ -70,9 +70,10 @@ public class QuartzExecutors {
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.
if (INSTANCE == null) {
- INSTANCE = new QuartzExecutors();
+ QuartzExecutors quartzExecutors = new QuartzExecutors();
//finish QuartzExecutors init
- INSTANCE.init();
+ quartzExecutors.init();
+ INSTANCE = quartzExecutors;
}
}
}