You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by we...@apache.org on 2022/09/30 22:57:26 UTC

[dolphinscheduler] branch dev updated: Fix hive datasource connection leak (#12226)

This is an automated email from the ASF dual-hosted git repository.

wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 0a44107bf9 Fix hive datasource connection leak (#12226)
0a44107bf9 is described below

commit 0a44107bf9fdf758eedab06b1fe35ad9dc6a0791
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Sat Oct 1 06:57:12 2022 +0800

    Fix hive datasource connection leak (#12226)
---
 .../plugin/datasource/hive/HiveDataSourceClient.java       | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java
index 0cef82c1b5..d076e81c9a 100644
--- a/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java
+++ b/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java
@@ -45,6 +45,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
@@ -79,8 +80,8 @@ public class HiveDataSourceClient extends CommonDataSourceClient {
         this.ugi = createUserGroupInformation(baseConnectionParam.getUser());
         logger.info("Create ugi success.");
 
-        super.initClient(baseConnectionParam, dbType);
         this.dataSource = JDBCDataSourceProvider.createOneSessionJdbcDataSource(baseConnectionParam, dbType);
+        this.jdbcTemplate = new JdbcTemplate(dataSource);
         logger.info("Init {} success.", getClass().getName());
     }
 
@@ -166,10 +167,13 @@ public class HiveDataSourceClient extends CommonDataSourceClient {
 
     @Override
     public void close() {
-        super.close();
+        try {
+            super.close();
+        } finally {
+            kerberosRenewalService.shutdown();
+            this.ugi = null;
+        }
+        logger.info("Closed Hive datasource client.");
 
-        logger.info("close {}.", this.getClass().getSimpleName());
-        kerberosRenewalService.shutdown();
-        this.ugi = null;
     }
 }