Commons Dbcp
  1. Commons Dbcp
  2. DBCP-288

DelegatingConnection implicitly casts AbandonedTrace to Statement

    Details

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

      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.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Marc Kannegießer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development