You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by Ted Dunning <te...@gmail.com> on 2009/09/09 18:33:40 UTC

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

How does IOUtils do this?

On Wed, Sep 9, 2009 at 2:37 AM, Sean Owen (JIRA) <ji...@apache.org> wrote:

> > Uses IOUtils consistently to close Closeables,
>



-- 
Ted Dunning, CTO
DeepDyve

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Sean Owen <sr...@gmail.com>.
Not sure I really highlighted the punchline, reason it might ever
matter -- if you have more than one Closeable to close() in a block,
you probably need to do something like this. If the first one fails to
close, you miss closing the second. Unless you write some funky nested
finally blocks and such.

On Wed, Sep 9, 2009 at 5:37 PM, Sean Owen<sr...@gmail.com> wrote:
> That's 7 lines I don't need to repeat all over the place. It came in
> very handy to convert 3x7 = 21 such lines into 1 since a JDBC call
> involves 3 closeable things -- Connection, Statement, ResultSet. This
> is for the common case that some failure on closing something you're
> done reading is... noteworthy but probably not a reason to just stop
> immediately with an exception.
>

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Ted Dunning <te...@gmail.com>.
Cool.  It just suddenly sounded like finalizers were creeping in with the
assumption that they would handle closing files.

On Wed, Sep 9, 2009 at 9:37 AM, Sean Owen <sr...@gmail.com> wrote:

> It just packs up this...
> ...
> That's 7 lines I don't need to repeat all over the place.
>



-- 
Ted Dunning, CTO
DeepDyve

Re: [jira] Updated: (MAHOUT-175) Use IOUtils, FileLineIterable/Iterator across the project

Posted by Sean Owen <sr...@gmail.com>.
It just packs up this...

if (closeable != null) {
  try {
    closeable.close();
  } catch (IOException ioe) {
    log.warning(ioe);
  }
}

That's 7 lines I don't need to repeat all over the place. It came in
very handy to convert 3x7 = 21 such lines into 1 since a JDBC call
involves 3 closeable things -- Connection, Statement, ResultSet. This
is for the common case that some failure on closing something you're
done reading is... noteworthy but probably not a reason to just stop
immediately with an exception.

I didn't change any such calls where it seemed plausible that one
would definitely want to stop. Like unit tests.

On Wed, Sep 9, 2009 at 5:33 PM, Ted Dunning<te...@gmail.com> wrote:
> How does IOUtils do this?
>
> On Wed, Sep 9, 2009 at 2:37 AM, Sean Owen (JIRA) <ji...@apache.org> wrote:
>
>> > Uses IOUtils consistently to close Closeables,
>>
>
>
>
> --
> Ted Dunning, CTO
> DeepDyve
>