Closing a connection with "usageCount > 1" is possible.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Closing a connection with "usageCount > 1" is possible.

JdbcPooledConnection.close() says:

        // this should never happen, should we throw an exception or log at warn/error?
        if (usageCount > 0) {
            log.warn("close connection with usage count > 0, " + this);

However, should JdbcPooledConnection.getConnectionHandle() throw a SQLException because (e.g.) testConnection() has failed, then usageCount will still have been incremented when XAPool.getConnectionHandle() tries to close the invalid connection.

The patch is trivial:

    // Increment the usage count
    try {

       // etc

    } catch (SQLException e) {
        throw e;