Skip to content

chore: refactor JDBC tests to avoid leaking DataSource & friends - #5609

Open
jerrinot wants to merge 1 commit into
testcontainers:mainfrom
jerrinot:chore/leaking-ds-in-tests
Open

jerrinot wants to merge 1 commit into
testcontainers:mainfrom
jerrinot:chore/leaking-ds-in-tests

Conversation

@jerrinot

Copy link
Copy Markdown
Contributor

performQuery() is leaking DataSources, Connections and Statements.
Chances are it's also leaking ResutSets, unless a caller closes it. This is an attempt to fix it.

I kept the leaky method as there can be users outside the main repo.

I stumbled upon this while working on #5606

@jerrinot
jerrinot requested a review from a team July 24, 2022 11:23
@jerrinot

Copy link
Copy Markdown
Contributor Author

btw- if you think this is overkill then feel free to close it. no hard feelings :)

@eddumelendez eddumelendez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @jerrinot ! There is a couple of comments and we are ready to merge it.

Comment on lines +50 to +53
return getDataSource0(container);
}

private HikariDataSource getDataSource0(JdbcDatabaseContainer<?> container) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be kept. No need to create getDataSource0

* @return
* @throws SQLException
* @deprecated use {@link #assertQuery(JdbcDatabaseContainer, String, ResultSetConsumer)} instead.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*/
*/
@Deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants