[Fix](jdbc-scanner) Fix jdbc scanner memory leak because it didn't close outputTable. (#41266)

## Proposed changes

Backport #41041.
This commit is contained in:
Qi Chen
2024-09-25 17:35:13 +08:00
committed by GitHub
parent 869680bf38
commit 306af52aa2

View File

@ -99,6 +99,9 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor {
}
public void close() throws Exception {
if (outputTable != null) {
outputTable.close();
}
try {
if (stmt != null && !stmt.isClosed()) {
try {
@ -111,8 +114,8 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor {
if (conn != null && resultSet != null) {
abortReadConnection(conn, resultSet);
}
closeResources(resultSet, stmt, conn);
} finally {
closeResources(resultSet, stmt, conn);
if (config.getConnectionPoolMinSize() == 0 && hikariDataSource != null) {
hikariDataSource.close();
JdbcDataSource.getDataSource().getSourcesMap().remove(config.createCacheKey());