Velocity
  1. Velocity
  2. VELOCITY-760

DataSourceResourceLoader doesn't close PreparedStatements

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.2
    • Fix Version/s: 1.7, 2.x
    • Component/s: Engine
    • Labels:
      None

      Description

      DataSourceResourceLoader.java contains this method:

      private ResultSet readData(final Connection conn,
      final String columnNames,
      final String templateName) throws SQLException

      { PreparedStatement ps = conn.prepareStatement("SELECT " + columnNames + " FROM "+ tableName + " WHERE " + keyColumn + " = ?"); ps.setString(1, templateName); return ps.executeQuery(); }

      PreparedStatements created in this method never get closed, only the resultset returned may eventually be closed later which isn't sufficient for releasing all bound resources. In my project this statement leak lead to the oracle running out of open cursors (the infamous ORA-01000 error).

      1. velocity-760.patch
        3 kB
        Jarkko Viinamäki

        Activity

        Jerome Waibel created issue -
        Jerome Waibel made changes -
        Field Original Value New Value
        Description DataSourceResourceLoader.java contains this method:

        {code}
           private ResultSet readData(final Connection conn,
                                       final String columnNames,
                                       final String templateName) throws SQLException
            {
                PreparedStatement ps = conn.prepareStatement("SELECT " + columnNames + " FROM "+ tableName + " WHERE " + keyColumn + " = ?");
                ps.setString(1, templateName);
                return ps.executeQuery();
            }
        {code}

        PreparedStatements created in this method never get closed, only the resultset returned may eventually be closed later which isn't sufficient for releasing all bound resources. In my project this statement leak lead to the oracle running out of open cursors (the infamous ORA-01000 error).
        DataSourceResourceLoader.java contains this method:


           private ResultSet readData(final Connection conn,
                                       final String columnNames,
                                       final String templateName) throws SQLException
            {
                PreparedStatement ps = conn.prepareStatement("SELECT " + columnNames + " FROM "+ tableName + " WHERE " + keyColumn + " = ?");
                ps.setString(1, templateName);
                return ps.executeQuery();
            }


        PreparedStatements created in this method never get closed, only the resultset returned may eventually be closed later which isn't sufficient for releasing all bound resources. In my project this statement leak lead to the oracle running out of open cursors (the infamous ORA-01000 error).
        Jarkko Viinamäki made changes -
        Attachment velocity-760.patch [ 12442313 ]
        Nathan Bubna made changes -
        Fix Version/s 1.7 [ 12313453 ]
        Nathan Bubna made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0 [ 12310291 ]
        Resolution Fixed [ 1 ]
        Mark Thomas made changes -
        Workflow jira [ 12508686 ] Default workflow, editable Closed status [ 12551730 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551730 ] jira [ 12552268 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Jerome Waibel
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development