Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06D6B1797C for ; Wed, 4 Feb 2015 15:54:52 +0000 (UTC) Received: (qmail 24104 invoked by uid 500); 4 Feb 2015 15:54:52 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 23963 invoked by uid 500); 4 Feb 2015 15:54:52 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 23950 invoked by uid 99); 4 Feb 2015 15:54:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Feb 2015 15:54:52 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.220.173 as permitted sender) Received: from [209.85.220.173] (HELO mail-vc0-f173.google.com) (209.85.220.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Feb 2015 15:54:46 +0000 Received: by mail-vc0-f173.google.com with SMTP id id10so772605vcb.4 for ; Wed, 04 Feb 2015 07:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dsj2N+G2WmWJIrcBtqNqj0CYiU5nTuzch+0sqB9CqVM=; b=c7ECxAQjGCOA6eXxhnb+/UeMHirNyqi5J/BeTY+x/Un1VOpSaU6HbwnndI3sPmoNpb 1lcTGfAXN3K7AZaBhjXaktqt4ScKtS9lbWWxw+GbvbRpkKqA1450OtpkY2M9CIOq6Mlk fErCYOacw3qIlGsXpk4IUm9zFJLDUVf7bmdYllA0AYCIKsU9GEaEa+P1ORg3crSSaJq9 xzukfHMMl6EDE1SU6yKjWSpt2vPq09sBQWm64EwQjzwT//AzhjPhhw9ZxOFLXQ54dd8a yVsz63zS9papqvVRgj1i+GMFiNBArnIxYn0MXGcQjyUO87WWlW9bAy2Dy5a6sxX20MEi h7cA== MIME-Version: 1.0 X-Received: by 10.221.2.197 with SMTP id nv5mr19781376vcb.53.1423065221301; Wed, 04 Feb 2015 07:53:41 -0800 (PST) Received: by 10.52.36.174 with HTTP; Wed, 4 Feb 2015 07:53:41 -0800 (PST) In-Reply-To: <54D223EB.80300@gmail.com> References: <54D223EB.80300@gmail.com> Date: Wed, 4 Feb 2015 15:53:41 +0000 Message-ID: Subject: Re: [DBCP] needless sync on getNumActive, getNumIdle? From: sebb To: Commons Developers List Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org On 4 February 2015 at 13:51, Phil Steitz wrote: > I had to go around getNumIdle to avoid waiting on a this lock in the > unit test I just committed. With pool 2 and volatile connectionPool > instance, I don't think this sync is needed any more. Same with the > sync on getNumActive. Am I missing something here? I think there are two potential issues here. The first is that getNumIdle will fail with NPE if another thread closes the pool in the meantime. That can be handled by taking a copy of the reference first. The second possible issue is ensuring safe publication - I think volatile should be sufficient here. > Phil > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org