Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 95A59108C9 for ; Tue, 3 Dec 2013 09:36:45 +0000 (UTC) Received: (qmail 71919 invoked by uid 500); 3 Dec 2013 09:36:38 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 71879 invoked by uid 500); 3 Dec 2013 09:36:35 -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 71867 invoked by uid 99); 3 Dec 2013 09:36:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Dec 2013 09:36:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Tue, 03 Dec 2013 09:36:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 92CA82388994; Tue, 3 Dec 2013 09:36:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1547326 - in /commons/proper/dbcp/trunk/src: changes/changes.xml java/org/apache/commons/dbcp2/PoolingDriver.java test/org/apache/commons/dbcp2/TestPoolingDriver.java Date: Tue, 03 Dec 2013 09:36:12 -0000 To: commits@commons.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131203093612.92CA82388994@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Tue Dec 3 09:36:12 2013 New Revision: 1547326 URL: http://svn.apache.org/r1547326 Log: DBCP-384 Fix threading issues with PoolingDriver.accessToUnderlyingConnectionAllowed Modified: commons/proper/dbcp/trunk/src/changes/changes.xml commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingDriver.java commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java Modified: commons/proper/dbcp/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1547326&r1=1547325&r2=1547326&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/changes/changes.xml (original) +++ commons/proper/dbcp/trunk/src/changes/changes.xml Tue Dec 3 09:36:12 2013 @@ -78,6 +78,10 @@ The type attribute can be add,u Remove deprecated SQLNestedException. + + Fix threading issues with accessToUnderlyingConnectionAllowed attribute + of PoolingDriver which is used to support unit testing. + Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingDriver.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingDriver.java?rev=1547326&r1=1547325&r2=1547326&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingDriver.java (original) +++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolingDriver.java Tue Dec 3 09:36:12 2013 @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.commons.dbcp2; import java.sql.CallableStatement; @@ -61,29 +60,27 @@ public class PoolingDriver implements Dr new HashMap<>(); /** Controls access to the underlying connection */ - private static boolean accessToUnderlyingConnectionAllowed = false; + private final boolean accessToUnderlyingConnectionAllowed; public PoolingDriver() { + this(true); } /** - * Returns the value of the accessToUnderlyingConnectionAllowed property. - * - * @return true if access to the underlying is allowed, false otherwise. + * For unit testing purposes. */ - public static synchronized boolean isAccessToUnderlyingConnectionAllowed() { - return accessToUnderlyingConnectionAllowed; + protected PoolingDriver(boolean accessToUnderlyingConnectionAllowed) { + this.accessToUnderlyingConnectionAllowed = accessToUnderlyingConnectionAllowed; } - + + /** - * Sets the value of the accessToUnderlyingConnectionAllowed property. - * It controls if the PoolGuard allows access to the underlying connection. - * (Default: false) + * Returns the value of the accessToUnderlyingConnectionAllowed property. * - * @param allow Access to the underlying connection is granted when true. + * @return true if access to the underlying is allowed, false otherwise. */ - public static synchronized void setAccessToUnderlyingConnectionAllowed(boolean allow) { - accessToUnderlyingConnectionAllowed = allow; + protected boolean isAccessToUnderlyingConnectionAllowed() { + return accessToUnderlyingConnectionAllowed; } public synchronized ObjectPool getConnectionPool(String name) @@ -219,7 +216,7 @@ public class PoolingDriver implements Dr * PoolGuardConnectionWrapper is a Connection wrapper that makes sure a * closed connection cannot be used anymore. */ - static private class PoolGuardConnectionWrapper extends DelegatingConnection { + private class PoolGuardConnectionWrapper extends DelegatingConnection { private final ObjectPool pool; private Connection delegate; Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java?rev=1547326&r1=1547325&r2=1547326&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java (original) +++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/TestPoolingDriver.java Tue Dec 3 09:36:12 2013 @@ -80,9 +80,8 @@ public class TestPoolingDriver extends T pcf.setPool(pool); assertNotNull(pcf); - driver = new PoolingDriver(); + driver = new PoolingDriver(true); driver.registerPool("test",pool); - PoolingDriver.setAccessToUnderlyingConnectionAllowed(true); } @Override