Commons Dbcp
  1. Commons Dbcp
  2. DBCP-5

[dbcp] PoolGuardConnectionWrapper violates close() contract

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      org.apache.commons.dbcp.PoolingDatasource.PoolGuardConnectionWrapper.close()
      violates the Connection.close() contract specified in the Java 1.5 API. The
      current API specifies that calling close() on an already-closed connection is a
      no-op. (Blame Sun for the bug. The API didn't used to say that.)

      PoolGuardConnectionWrapper.close() first calls checkOpen() which throws an
      exception if close() has already been called. Clearly that's not a no-op.

      The simplest fix is to change the first line in the close() method from this:
      checkOpen();

      to this:
      if (this.delegate == null) return;

      As of today (2006-03-22) this bug is in the latest SVN source (and has been in
      previous versions as well).

      DelegatingConnection and PoolingConnection don't seem (from a quick glance) to
      have this problem.

        Activity

        Hide
        Sandy McArthur (from Bugzilla import) added a comment -

        This has come up before and a few weeks ago I found a number of close methods
        that needed to be changed. See:
        http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/200603.mbox/%3c6bde122b0603072304h20460a9ewc7d7e1eaa70f440@mail.gmail.com%3e

        Show
        Sandy McArthur (from Bugzilla import) added a comment - This has come up before and a few weeks ago I found a number of close methods that needed to be changed. See: http://mail-archives.apache.org/mod_mbox/jakarta-commons-dev/200603.mbox/%3c6bde122b0603072304h20460a9ewc7d7e1eaa70f440@mail.gmail.com%3e
        Hide
        Phil Steitz added a comment -

        Fixed in r 557176.

        Show
        Phil Steitz added a comment - Fixed in r 557176.

          People

          • Assignee:
            Unassigned
            Reporter:
            Derek Park
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development