[jira] [Commented] (VELOCITY-989) Multiple connection leaks in DataSourceResourceLoader
"Francis M Schlimmer (Jira)" <[email protected]>
| Newsgroups | gmane.comp.jakarta.velocity.devel |
|---|---|
| Message-ID | <[email protected]> |
[ https://issues.apache.org/jira/browse/VELOCITY-989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17951103#comment-17951103 ]
Francis M Schlimmer commented on VELOCITY-989:
----------------------------------------------
I updated the PR with a fix that I don't love but I can't find a way to do it differently without changing the API of DatabaseObjectsFactory. I updated the factory to return a proxy of Statement and ResultSet that guarantees Statement.getConnection and ResultSet.getStatement behave in a way that will not cause issues.
However I would prefer to change DatabaseObjectsFactory.prepareStatement and DatabaseObjectsFactory.releaseStatement to use an explicit wrapper object instead. This would avoid the somewhat hard to follow proxy code and would be a bit more obvious to anyone writing custom implementations of DatabaseObjectsFactory that the original connection and statement are needed rather then relying on Statement.getConnection or ResultSet.getStatement.
> Multiple connection leaks in DataSourceResourceLoader
> -----------------------------------------------------
>
> Key: VELOCITY-989
> URL: https://issues.apache.org/jira/browse/VELOCITY-989
> Project: Velocity
> Issue Type: Bug
> Reporter: Francis M Schlimmer
> Priority: Major
>
> The first case is in the implementation of FilterReader. It attempts to get a statement from a result set after closing the result set. This always throws an exception as it is an invalid operation after closing the result set, which results in not closing the connection.
> The second is in the getResourceReader method. In the happy path a FilterReader is returned which eventually closes the connection when close is called. However, if a template is not found, an exception is thrown without closing the connection.
>
> Pull request here [https://github.com/apache/velocity-engine/pull/57]
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)