commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [lang] New feature: Close method for Objects
Date Sun, 30 Jun 2002 22:50:34 GMT
I would suggest that IO is a better home for the close method.

Also, I would definitely not want Lang to have Logging.

Stephen

----- Original Message -----
From: "Henri Yandell" <bayard@generationjava.com>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Sunday, June 30, 2002 10:44 PM
Subject: Re: [lang] New feature: Close method for Objects


> My only worry with this one is logging.
>
> When errors occur in lang, and Exceptions are being supressed, what form
> of logging should occur? Or do we just make them quiet.
>
> Lastly, what performance drop do you see from using the reflection here?
> I'll assume you're caching the Method objects, so performance shouldn't be
> that big an issue.
>
> Hen
>
> On Sun, 30 Jun 2002, Rand McNeely wrote:
>
> > I've attached a close method for Objects.  It uses reflection to call
> > close on the object passed to it and returns any exceptions (without
> > throwing them).  I have found this to be very useful as most classes
> > which have a close method declare to throw an exception that can't be
> > dealt with in a meaningful way (java.io.InputStream,
> > java.sql.Connection, etc).  This leads to constructs like this:
> >
> > finally {
> > try {
> > if (statement != null) {
> > statement.close();
> > }
> > } catch (SQLException ignored) {
> > }
> > try {
> > if (connection != null) {
> > connection.close();
> > }
> > } catch (SQLException ignored) { }
> > }
> > }
> >
> > which would be much cleaner like this:
> >
> > finally {
> > Objects.close(statement);
> > Objects.close(connection);
> > }
> >
> > Rand McNeely
> >
>
>
> --
> To unsubscribe, e-mail:
<mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message