Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null) #2184

Merged
merged 2 commits into from Jan 15, 2024

Conversation

CarlosRuiz-globalqss
Copy link
Collaborator

@CarlosRuiz-globalqss CarlosRuiz-globalqss commented Jan 11, 2024

https://idempiere.atlassian.net/browse/IDEMPIERE-5994

Pull Request Checklist

  • My code follows the code guidelines of this project
  • My code follows the best practices of this project
  • I have performed a self-review of my own code
  • My code is easy to understand and review.
  • I have checked my code and corrected any misspellings
  • In hard-to-understand areas, I have commented my code.
  • My changes generate no new warnings

Tests

  • I have tested the direct scenario that my code is solving
  • I checked all collaterals that can be affected by my changes, and tested other potential affected scenarios
  • New and existing unit tests pass locally with my changes
  • I have added unit tests that prove my fix is effective or that my feature works

@CarlosRuiz-globalqss CarlosRuiz-globalqss marked this pull request as draft January 11, 2024 18:45
@CarlosRuiz-globalqss CarlosRuiz-globalqss marked this pull request as ready for review January 11, 2024 22:14
m_conn.close();
m_conn = null;
} catch (SQLException e1) {}
}
Copy link
Collaborator

@hengsin hengsin Jan 13, 2024

Choose a reason for hiding this comment

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

doesn't need the localConn stuff, just need to call this.close() here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @hengsin
this.close() is not available at this point
the "localconn" is to avoid closing a connection that is managed elsewhere, I just need to close here the connections created locally in the same method.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, you need to change StatementProxy.close to protected. Calling the close method of StatementProxy should be the correct approach here, not the method above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @hengsin - tested your suggestion and it worked fine.

m_conn.close();
m_conn = null;
} catch (SQLException e1) {}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, you need to change StatementProxy.close to protected. Calling the close method of StatementProxy should be the correct approach here, not the method above.

Copy link
Collaborator

@hengsin hengsin left a comment

Choose a reason for hiding this comment

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

looks good

@hengsin hengsin merged commit 067d2ea into idempiere:master Jan 15, 2024
4 checks passed
CarlosRuiz-globalqss added a commit that referenced this pull request Jan 23, 2024
… null) (#2184)

* IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null)

* - implement approach suggested by Heng Sin
CarlosRuiz-globalqss added a commit that referenced this pull request Feb 6, 2024
… null) (#2184)

* IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null)

* - implement approach suggested by Heng Sin
@CarlosRuiz-globalqss CarlosRuiz-globalqss deleted the IDEMPIERE-5994-Fix branch February 7, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants