https://bz.apache.org/bugzilla/show_bug.cgi?id=61022

            Bug ID: 61022
           Summary: Returning Closed Connections to the Pool
           Product: Tomcat Modules
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: jdbc-pool
          Assignee: dev@tomcat.apache.org
          Reporter: g...@hilbertinc.com
  Target Milestone: ---

The connection pool was returning a closed connection to the pool.  The root
cause of this was that my code was accessing the underlying ("real") connection
and closing it.  My code snipped follows:

   private void onResultSetExhausted() throws SQLException {
      if (!getResultSet().isClosed()) {
         Statement statement = getResultSet().getStatement();
         if (!statement.isClosed()) {
            Connection connection = statement.getConnection();
            getResultSet().getStatement().close();
            if (!connection.isClosed()) {
               connection.close();
            }
         }
         getResultSet().close();
      }
   }

This implies that the problem may be a regression of the problem described in
48392.  My proposed solution is to check the real connection state in the
ProxyConnection::invoke method.  A snippet of that code is:

        if (compare(CLOSE_VAL,method)) {
            if (connection==null) return null; //noop for already closed.
            PooledConnection poolc = this.connection;
            this.connection = null;
            if (!poolc.getConnection().isClosed()) { // <-- Added this
                pool.returnConnection(poolc);
            }
            return null;
        } else if (compare(TOSTRING_VAL,method)) {

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to