Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 77598 invoked from network); 27 Sep 2004 19:07:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 27 Sep 2004 19:07:40 -0000 Received: (qmail 66692 invoked by uid 500); 27 Sep 2004 19:06:16 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 66509 invoked by uid 500); 27 Sep 2004 19:06:15 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 66496 invoked by uid 99); 27 Sep 2004 19:06:14 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [64.236.240.147] (HELO smtpgw2.turner.com) (64.236.240.147) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 27 Sep 2004 12:06:12 -0700 Received: from cnncimss03.turner.com (CNNCIMSS03.turner.com [10.188.169.203]) by smtpgw2.turner.com (8.12.10/8.12.11) with ESMTP id i8RJ6A77027892 for ; Mon, 27 Sep 2004 15:06:10 -0400 (EDT) Received: from cnncmx06.turner.com ([10.188.169.216]) by cnncimss03.turner.com with InterScan Messaging Security Suite; Mon, 27 Sep 2004 15:06:09 -0400 Received: by cnncmx06.turner.com with Internet Mail Service (5.5.2657.72) id ; Mon, 27 Sep 2004 15:06:08 -0400 Message-ID: From: "Botelho, Mauro" To: "'Jakarta Commons Users List'" Subject: RE: [Pool] Use of Exception in API Date: Mon, 27 Sep 2004 15:07:15 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N What I think he's talking about is having a Pools exception, e.g. org.apache.pools.PoolException that would nest the exception thrown. I think this is one of the "Effective Java" recommendations, but I don't have the book with me here to verify... Mauro -----Original Message----- From: Rodney Waldhoff [mailto:rwaldhoff@apache.org] Sent: Monday, September 27, 2004 2:36 PM To: Jakarta Commons Users List; tom.vandenberge@bibit.com Subject: Re: [Pool] Use of Exception in API On Mon, 20 Sep 2004, Tom van den Berge wrote: > Hi, Hi Tom. > > Hi recently started using the pool API, and I think it's a very useful API. > > However I noticed the frequent "throws Exception" declarations, which is > generally bad practice. Many of the core methods in the interfaces declare > it, so automatically all implementations are using it, too. It is not possible for the pool framework to know what kind of exceptions might be encountered in the underlying implementation (e.g., in createObject of PoolableObjectFactory). Hence a generic Exception type is used. Consider, for example, the SQLException thrown by DBCP. Alternatives might include swallowing the exception quietly (much worse) or tunneling the exception in a RuntimeException (arguably no better than current). Fundamentally this is a drawback to a strongly typed, checked exception system. I don't see how "replacing Exception with more specific exceptions" could possibly work in the general case. - R > > One example is the borrowObject method from ObjectPool. The implementing > class GenericObjectPool calls a couple of methods from > PoolableObjectFactory, which also throw Exception, and the method itself > also throws an Exception. > > Are there any plans scheduled for refactoring these issues throughout the > API? > > Since the code is fairly small in size and compact, it shouldn't be too > much effort, and the code will improve greatly. Backward compatibility is > not an issue since you would typically replace the Exceptions with more > specific exceptions. > > Regards, > Tom --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org