Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 10237 invoked from network); 21 Jun 2009 16:41:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Jun 2009 16:41:30 -0000 Received: (qmail 49281 invoked by uid 500); 21 Jun 2009 16:41:41 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 49182 invoked by uid 500); 21 Jun 2009 16:41:40 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 49173 invoked by uid 99); 21 Jun 2009 16:41:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jun 2009 16:41:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Jun 2009 16:41:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AF36123888D3; Sun, 21 Jun 2009 16:41:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r787049 - /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java Date: Sun, 21 Jun 2009 16:41:18 -0000 To: commits@commons.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090621164118.AF36123888D3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Sun Jun 21 16:41:18 2009 New Revision: 787049 URL: http://svn.apache.org/viewvc?rev=787049&view=rev Log: Fix DBCP-288. When passivating a DelegatingConnection, not all of the trace objects will be statements so check each one before casting and closing. Based on a patch provided by Marc Kannegießer Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java?rev=787049&r1=787048&r2=787049&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java (original) +++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java Sun Jun 21 16:41:18 2009 @@ -24,6 +24,7 @@ import java.sql.SQLException; import java.sql.SQLWarning; import java.sql.Statement; +import java.util.Iterator; import java.util.List; import java.util.Map; /* JDBC_4_ANT_KEY_BEGIN */ @@ -410,12 +411,15 @@ try { // The JDBC spec requires that a Connection close any open // Statement's when it is closed. - 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(); + // POOL-288. Not all the traced objects will be statements + List traces = getTrace(); + if(traces != null) { + Iterator traceIter = traces.iterator(); + while (traceIter.hasNext()) { + Object trace = traceIter.next(); + if (trace instanceof Statement) { + ((Statement) trace).close(); + } } clearTrace(); }