This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new a7ab7678543 branch-3.0: [fix](jdbc catalog) Fix connection leak in
PostgreSQL JDBC client #49568 (#49760)
a7ab7678543 is described below
commit a7ab7678543b3d7d95ed95f0585790d8f05995e1
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Apr 7 16:56:08 2025 +0800
branch-3.0: [fix](jdbc catalog) Fix connection leak in PostgreSQL JDBC
client #49568 (#49760)
Cherry-picked from #49568
Co-authored-by: zy-kkk <[email protected]>
---
.../jdbc/client/JdbcPostgreSQLClient.java | 26 +++++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcPostgreSQLClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcPostgreSQLClient.java
index 21c16f2dd20..fe1e365d1ac 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcPostgreSQLClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcPostgreSQLClient.java
@@ -65,12 +65,26 @@ public class JdbcPostgreSQLClient extends JdbcClient {
int arrayDimensions = 0;
if (dataType == Types.ARRAY) {
String columnName = rs.getString("COLUMN_NAME");
- try (PreparedStatement pstmt = conn.prepareStatement(
- String.format("SELECT array_ndims(%s) FROM %s.%s
LIMIT 1",
- columnName, remoteDbName,
remoteTableName))) {
- try (ResultSet arrayRs = pstmt.executeQuery()) {
- if (arrayRs.next()) {
- arrayDimensions = arrayRs.getInt(1);
+ PreparedStatement pstmt = null;
+ ResultSet arrayRs = null;
+ try {
+ pstmt = conn.prepareStatement(
+ String.format("SELECT array_ndims(%s) FROM
%s.%s LIMIT 1",
+ columnName, remoteDbName,
remoteTableName));
+ arrayRs = pstmt.executeQuery();
+ if (arrayRs.next()) {
+ arrayDimensions = arrayRs.getInt(1);
+ }
+ } catch (SQLException ex) {
+ LOG.warn("Failed to get array dimensions for column
{}: {}",
+ columnName, Util.getRootCauseMessage(ex));
+ } finally {
+ close(arrayRs, null);
+ if (pstmt != null) {
+ try {
+ pstmt.close();
+ } catch (SQLException ex) {
+ LOG.warn("Failed to close prepared statement:
{}", Util.getRootCauseMessage(ex));
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]