Skip to content

Commit

Permalink
Fix hive datasource connection leak (apache#12226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanwenjun authored and xdu-chenrj committed Oct 13, 2022
1 parent d20a679 commit 6c58d64
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

Expand Down Expand Up @@ -79,8 +80,8 @@ protected void initClient(BaseConnectionParam baseConnectionParam, DbType dbType
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());
}

Expand Down Expand Up @@ -166,10 +167,13 @@ public Connection getConnection() {

@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;
}
}

0 comments on commit 6c58d64

Please sign in to comment.