From 60457284286b06007c06a1efef7f9706ca848320 Mon Sep 17 00:00:00 2001 From: Jiajie Zhong Date: Sat, 13 Nov 2021 16:47:29 +0800 Subject: [PATCH] [ci] Add checkstyle prohibit rule System.out.println (#6778) * [ci] Add checkstyle prohibit rule System.out.println * Correct RegexpSingleline place --- .../common/utils/SnowFlakeUtilsTest.java | 17 +++++++++-------- .../common/utils/StringTest.java | 1 - .../dao/upgrade/UpgradeDao.java | 1 - .../hive/HiveDatasourceProcessorTest.java | 1 - .../mysql/MysqlDatasourceProcessorTest.java | 1 - .../registry/WorkerRegistryClientTest.java | 1 - .../queue/TaskPriorityQueueImplTest.java | 2 -- style/checkstyle.xml | 5 +++++ 8 files changed, 14 insertions(+), 15 deletions(-) diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java index bdf7096ba6..e72e87f2c6 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtilsTest.java @@ -17,18 +17,19 @@ package org.apache.dolphinscheduler.common.utils; +import java.util.HashSet; + +import org.junit.Assert; import org.junit.Test; public class SnowFlakeUtilsTest { @Test - public void testNextId() { - try { - for (int i = 0; i < 100; i++) { - Thread.sleep(1); - System.out.println(SnowFlakeUtils.getInstance().nextId()); - } - } catch (Exception e) { - e.printStackTrace(); + public void testNoGenerateDuplicateId() throws SnowFlakeUtils.SnowFlakeException { + HashSet existsSnowFlakeId = new HashSet<>(); + for (int i = 0; i < 100; i++) { + Long currentId = SnowFlakeUtils.getInstance().nextId(); + Assert.assertFalse(existsSnowFlakeId.contains(currentId)); + existsSnowFlakeId.add(currentId); } } } diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java index b14be21e60..0f8055d6bb 100644 --- a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java +++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/StringTest.java @@ -47,7 +47,6 @@ public class StringTest { } } double during = (System.currentTimeMillis() - start) / 1000.0; - System.out.println(during); Assert.assertEquals("1_0000000000_0000000001", origin); } } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java index 9325f17c3f..d232cf9826 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java @@ -671,7 +671,6 @@ public abstract class UpgradeDao { taskDefinitionLog.setName(name); taskDefinitionLog.setWorkerGroup(task.get("workerGroup").asText()); long taskCode = SnowFlakeUtils.getInstance().nextId(); - // System.out.println(taskCode); taskDefinitionLog.setCode(taskCode); taskDefinitionLog.setVersion(Constants.VERSION_FIRST); taskDefinitionLog.setProjectCode(processDefinition.getProjectCode()); diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java index 89ca40966f..84e8fd8898 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java @@ -59,7 +59,6 @@ public class HiveDatasourceProcessorTest { PowerMockito.when(CommonUtils.getKerberosStartupState()).thenReturn(false); HiveConnectionParam connectionParams = (HiveConnectionParam) hiveDatasourceProcessor .createConnectionParams(hiveDataSourceParamDTO); - System.out.println(JSONUtils.toJsonString(connectionParams)); Assert.assertNotNull(connectionParams); Assert.assertEquals("jdbc:hive2://localhost1:5142,localhost2:5142", connectionParams.getAddress()); } diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java index eef74f4bcf..beeda1e9db 100644 --- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java +++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java @@ -58,7 +58,6 @@ public class MysqlDatasourceProcessorTest { PowerMockito.when(PasswordUtils.encodePassword(Mockito.anyString())).thenReturn("test"); MysqlConnectionParam connectionParams = (MysqlConnectionParam) mysqlDatasourceProcessor .createConnectionParams(mysqlDatasourceParamDTO); - System.out.println(JSONUtils.toJsonString(connectionParams)); Assert.assertEquals("jdbc:mysql://localhost:3306", connectionParams.getAddress()); Assert.assertEquals("jdbc:mysql://localhost:3306/default", connectionParams.getJdbcUrl()); } diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java index bbc131dc95..d12cefb6f6 100644 --- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java +++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/registry/WorkerRegistryClientTest.java @@ -81,7 +81,6 @@ public class WorkerRegistryClientTest { @Test public void testRegistry() { //workerRegistryClient.initWorkRegistry(); - // System.out.println(this.workerGroups.iterator()); //Set workerGroups = Sets.newHashSet("127.0.0.1"); //workerRegistryClient.registry(); // workerRegistryClient.handleDeadServer(); diff --git a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java index d90011b847..3888d3d93c 100644 --- a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java +++ b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/queue/TaskPriorityQueueImplTest.java @@ -103,9 +103,7 @@ public class TaskPriorityQueueImplTest { queue.poll(1000, TimeUnit.MILLISECONDS); queue.poll(1000, TimeUnit.MILLISECONDS); Assert.assertTrue(queue.size() == 0); - System.out.println(System.currentTimeMillis()); queue.poll(1000, TimeUnit.MILLISECONDS); - System.out.println(System.currentTimeMillis()); } @Test diff --git a/style/checkstyle.xml b/style/checkstyle.xml index 48340ed9e3..08bb05b108 100644 --- a/style/checkstyle.xml +++ b/style/checkstyle.xml @@ -34,6 +34,11 @@ + + + + +