branch-3.0: [fix](jdbc catalog) Optimize JDBC Connection Closing to Ensure ProperResource Release#43105
Closed
github-actions[bot] wants to merge 1 commit intobranch-3.0from
Closed
branch-3.0: [fix](jdbc catalog) Optimize JDBC Connection Closing to Ensure ProperResource Release#43105github-actions[bot] wants to merge 1 commit intobranch-3.0from
github-actions[bot] wants to merge 1 commit intobranch-3.0from
Conversation
…Resource Release (#43059) This pull request optimizes the JDBC connection and resource management in `JdbcClient` and related methods. The main changes are as follows: - **Manual Resource Closing**: Explicitly place resource acquisition and closing within a `try-catch-finally` structure. In the `finally` block, manually close resources like `Connection`, `Statement`, and `ResultSet` to ensure that resources are properly released even if an exception occurs. - **Remove try-with-resources**: All usages of `try-with-resources` have been removed, switching to manual resource management instead. - **Improve Exception Handling**: When closing resources, if an exception occurs, log a warning but do not throw a new exception. This avoids masking the original exception during the resource release phase. - **Unified Resource Management**: Ensure consistent resource acquisition and closing methods across all functions, improving code readability and maintainability. Functions modified include but are not limited to: - `executeStmt` - `getColumnsFromQuery` - `getDatabaseNameList` - `getJdbcColumnsInfo` - `processTable` - `getColumnsDataTypeUseQuery` These changes enhance the robustness of the code, prevent potential resource leaks, and ensure that all JDBC connections and resources are properly closed without using `try-with-resources`.
Contributor
Author
|
run buildall |
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
Contributor
|
run buildall |
TPC-H: Total hot run time: 40131 ms |
TPC-DS: Total hot run time: 193043 ms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Body: This pull request optimizes the JDBC connection and resource management in
JdbcClientand related methods. The main changes are as follows:Manual Resource Closing: Explicitly place resource acquisition and closing within a
try-catch-finallystructure. In thefinallyblock, manually close resources likeConnection,Statement, andResultSetto ensure that resources are properly released even if an exception occurs.Remove try-with-resources: All usages of
try-with-resourceshave been removed, switching to manual resource management instead.Improve Exception Handling: When closing resources, if an exception occurs, log a warning but do not throw a new exception. This avoids masking the original exception during the resource release phase.
Unified Resource Management: Ensure consistent resource acquisition and closing methods across all functions, improving code readability and maintainability.
Functions modified include but are not limited to:
executeStmtgetColumnsFromQuerygetDatabaseNameListgetJdbcColumnsInfoprocessTablegetColumnsDataTypeUseQueryThese changes enhance the robustness of the code, prevent potential resource leaks, and ensure that all JDBC connections and resources are properly closed without using
try-with-resources.Cherry-picked from #43059