Browse Source

fix sonar bug: null check & clean throw exception (#1690)

* fix sonar bug: null check & clean throw exception

* fix sonar bug: null check & clean throw exception
pull/2/head
Yelli 5 years ago committed by qiaozhanwei
parent
commit
216154dc06
  1. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
  2. 7
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java
  3. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java
  4. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java
  5. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java
  6. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java
  7. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java
  8. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java
  9. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java
  10. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java
  11. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java
  12. 1
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java
  13. 3
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java
  14. 12
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java

@ -195,12 +195,11 @@ public class ProcessInstanceService extends BaseDAGService {
processInstance.setDuration(DateUtils.differSec(processInstance.getStartTime(),processInstance.getEndTime())); processInstance.setDuration(DateUtils.differSec(processInstance.getStartTime(),processInstance.getEndTime()));
} }
Set<String> exclusionSet = new HashSet<String>(){{ Set<String> exclusionSet = new HashSet<String>();
add(Constants.CLASS); exclusionSet.add(Constants.CLASS);
add("locations"); exclusionSet.add("locations");
add("connects"); exclusionSet.add("connects");
add("processInstanceJson"); exclusionSet.add("processInstanceJson");
}};
PageInfo pageInfo = new PageInfo<ProcessInstance>(pageNo, pageSize); PageInfo pageInfo = new PageInfo<ProcessInstance>(pageNo, pageSize);
pageInfo.setTotalCount((int) processInstanceList.getTotal()); pageInfo.setTotalCount((int) processInstanceList.getTotal());

7
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/TaskInstanceService.java

@ -116,10 +116,9 @@ public class TaskInstanceService extends BaseService {
page, project.getId(), processInstanceId, searchVal, taskName, statusArray, host, start, end page, project.getId(), processInstanceId, searchVal, taskName, statusArray, host, start, end
); );
PageInfo pageInfo = new PageInfo<ProcessInstance>(pageNo, pageSize); PageInfo pageInfo = new PageInfo<ProcessInstance>(pageNo, pageSize);
Set<String> exclusionSet = new HashSet<String>(){{ Set<String> exclusionSet = new HashSet<>();
add(Constants.CLASS); exclusionSet.add(Constants.CLASS);
add("taskJson"); exclusionSet.add("taskJson");
}};
List<TaskInstance> taskInstanceList = taskInstanceIPage.getRecords(); List<TaskInstance> taskInstanceList = taskInstanceIPage.getRecords();
for(TaskInstance taskInstance : taskInstanceList){ for(TaskInstance taskInstance : taskInstanceList){
taskInstance.setDuration(DateUtils.differSec(taskInstance.getStartTime(), taskInstance.setDuration(DateUtils.differSec(taskInstance.getStartTime(),

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/ClickHouseDataSource.java

@ -66,7 +66,6 @@ public class ClickHouseDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("ClickHouse datasource try conn close conn error", e); logger.error("ClickHouse datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/DB2ServerDataSource.java

@ -66,7 +66,6 @@ public class DB2ServerDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("DB2 Server datasource try conn close conn error", e); logger.error("DB2 Server datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/HiveDataSource.java

@ -69,7 +69,6 @@ public class HiveDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("hive datasource try conn close conn error", e); logger.error("hive datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/MySQLDataSource.java

@ -64,7 +64,6 @@ public class MySQLDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("Mysql datasource try conn close conn error", e); logger.error("Mysql datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/OracleDataSource.java

@ -66,7 +66,6 @@ public class OracleDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("Oracle datasource try conn close conn error", e); logger.error("Oracle datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/PostgreDataSource.java

@ -68,7 +68,6 @@ public class PostgreDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("Postgre datasource try conn close conn error", e); logger.error("Postgre datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SQLServerDataSource.java

@ -62,7 +62,6 @@ public class SQLServerDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("SQL Server datasource try conn close conn error", e); logger.error("SQL Server datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/job/db/SparkDataSource.java

@ -71,7 +71,6 @@ public class SparkDataSource extends BaseDataSource {
con.close(); con.close();
} catch (SQLException e) { } catch (SQLException e) {
logger.error("Spark datasource try conn close conn error", e); logger.error("Spark datasource try conn close conn error", e);
throw e;
} }
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/DateInterval.java

@ -59,4 +59,5 @@ public class DateInterval {
public void setEndTime(Date endTime) { public void setEndTime(Date endTime) {
this.endTime = endTime; this.endTime = endTime;
} }
} }

1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNodeRelation.java

@ -53,6 +53,7 @@ public class TaskNodeRelation {
} }
@Override
public boolean equals(Object o){ public boolean equals(Object o){
if (!(o instanceof TaskNodeRelation)) { if (!(o instanceof TaskNodeRelation)) {
return false; return false;

3
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ConnectionUtils.java

@ -51,7 +51,6 @@ public class ConnectionUtils {
} }
} catch (SQLException e) { } catch (SQLException e) {
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
throw new RuntimeException(e);
} finally { } finally {
try { try {
if (stmt != null) { if (stmt != null) {
@ -60,7 +59,6 @@ public class ConnectionUtils {
} }
} catch (SQLException e) { } catch (SQLException e) {
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
throw new RuntimeException(e);
} finally { } finally {
try { try {
if (conn != null) { if (conn != null) {
@ -69,7 +67,6 @@ public class ConnectionUtils {
} }
} catch (SQLException e) { } catch (SQLException e) {
logger.error(e.getMessage(),e); logger.error(e.getMessage(),e);
throw new RuntimeException(e);
} }
} }
} }

12
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java

@ -155,7 +155,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) { } catch (Exception e) {
try { try {
conn.rollback(); if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) { } catch (SQLException e1) {
logger.error(e1.getMessage(),e1); logger.error(e1.getMessage(),e1);
} }
@ -312,7 +314,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e);
} catch (SQLException e) { } catch (SQLException e) {
try { try {
conn.rollback(); if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) { } catch (SQLException e1) {
logger.error(e1.getMessage(),e1); logger.error(e1.getMessage(),e1);
} }
@ -320,7 +324,9 @@ public abstract class UpgradeDao extends AbstractBaseDao {
throw new RuntimeException(e.getMessage(),e); throw new RuntimeException(e.getMessage(),e);
} catch (Exception e) { } catch (Exception e) {
try { try {
conn.rollback(); if (null != conn) {
conn.rollback();
}
} catch (SQLException e1) { } catch (SQLException e1) {
logger.error(e1.getMessage(),e1); logger.error(e1.getMessage(),e1);
} }

Loading…
Cancel
Save