Fix JDBC resource leaks in JdbcCatalog and JdbcUtil#15463
Open
PDGGK wants to merge 1 commit intoapache:mainfrom
Open
Fix JDBC resource leaks in JdbcCatalog and JdbcUtil#15463PDGGK wants to merge 1 commit intoapache:mainfrom
PDGGK wants to merge 1 commit intoapache:mainfrom
Conversation
Use try-with-resources for ResultSet and PreparedStatement objects in JdbcUtil.tableOrView(), JdbcCatalog.atomicCreateTable(), and JdbcCatalog.updateSchemaIfRequired() to ensure they are always closed even when exceptions occur. Closes apache#15462
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.
Description
Fixes 4 JDBC resource leaks in
JdbcCatalogandJdbcUtilby replacing manual resource management with try-with-resources.Closes #15462
Changes
JdbcUtil.java—tableOrView()ResultSet rs = sql.executeQuery()in try-with-resources. Previously a manualrs.close()existed but was skipped on exceptions, leaking theResultSet.JdbcCatalog.java—atomicCreateTable()dbMeta.getTables()ResultSetin try-with-resources (was never closed).conn.prepareStatement(sqlCommand)in try-with-resources (inline statement was never closed).JdbcCatalog.java—updateSchemaIfRequired()dbMeta.getColumns()ResultSetin try-with-resources (was never closed on either branch).conn.prepareStatement(V1_UPDATE_CATALOG_SQL)in try-with-resources (inline statement was never closed).Type of change
Checklist