commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Kannegießer (JIRA) <j...@apache.org>
Subject [jira] Updated: (DBCP-288) DelegatingConnection implicitly casts AbandonedTrace to Statement
Date Mon, 20 Apr 2009 09:40:50 GMT

     [ https://issues.apache.org/jira/browse/DBCP-288?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Marc Kannegießer updated DBCP-288:
----------------------------------

    Attachment: delegating_connection_close_statements.patch

This patch fixes the problem for me:
it iterates over the list and checks if the element is a Statement and explicitly casts it
to Statement if so. 

> 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
>
>         Attachments: delegating_connection_close_statements.patch
>
>
> 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.


Mime
View raw message