Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-288

DelegatingConnection implicitly casts AbandonedTrace to Statement

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3
    • 1.3
    • None

    Description

      If a ManagedConnection is put back to the connection pool it gets passivated (GenericObjectPool line 1101) by calling passivateObject() on the PoolableConnectionFactory which calls passivate() on the DelegatingConnection.

      passivate() in DelegatingConnection then executes the following code:

       
      List statements = getTrace();
      if( statements != null) {
        Statement[] set = new Statement[statements.size()];
        statements.toArray(set);
        for (int i = 0; i < set.length; i++) {
          set[i].close();
        }
        clearTrace();
      }
      

      This is an implicit cast from AbandonedTrace to Statement since getTrace() returns a list of AbandonedTrace instances.
      If the list contains other instances than those, that implement Statement an ArrayStoreException is thrown at statements.toArray(set) (line 416). See http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html#toArray() for details.

      I'd say this is a bug since AbandonedTrace does not implement Statement and there are derived classes that do not implement it also.

      In my case the list returned by getTrace() contains instances of DelegatingDatabaseMetaData which causes the mentioned ArrayStoreException.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kannegiesser Marc Kannegießer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: