DelegatingConnection implicitly casts AbandonedTrace to Statement
-----------------------------------------------------------------
Key: DBCP-288
URL: https://issues.apache.org/jira/browse/DBCP-288
Project: Commons Dbcp
Issue Type: Bug
Affects Versions: 1.3
Environment: I am using DBCP from svn-trunk (rev 766626).
I am using the BasicManagedDatasource with the MysqlXADataSource.
Configuration of BasicDataSource:
maxActive="10"
maxIdle="10"
maxWait="5000"
minIdle="0"
initialSize="2"
removeAbandoned="true"
removeAbandonedTimeout="120"
logAbandoned="true"
Reporter: Marc Kannegießer
Fix For: 1.3
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:
{code:java}
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();
}
{code}
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}}.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.