hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: HTableInterface to extend java.io.Closeable
Date Tue, 10 Jan 2012 17:37:53 GMT
This is an interesting idea.

HTable already implements Closeable.

Do you mind filing a JIRA (and optionally a patch) ?

Thanks

On Tue, Jan 10, 2012 at 2:57 AM, Ioan Eugen Stan <stan.ieugen@gmail.com>wrote:

> Hello,
>
> In my code I get to write a lot of boilerplate code to close a HTable
> instance (see below snippet). Making HTableInterface extent
> java.io.Closeable would allow developers to use IOUtils.closeQuietly()
> from appache-commons or a similar method to cose a HTable instance
> without the extra code. What do you think?
>
>       HTable table = null;
>        try {
>            table = new HTable(conf , "some table");
>            ResultScanner scanner = table.getScanner(scan);
>            Result result;
>            while ((result = scanner.next()) != null) {
>                 // do something
>            }
>            scanner.close();  // close the scanner
>        } catch (IOException e) {
>            LOG.error("Exception scanning in table");
>        } finally {
>         // close the table
>            if (table != null) {
>                try {
>                    table.close();
>                } catch (IOException e) {
>
>                }
>            }
>        }
>
>
> Cheers,
>
> --
> Ioan Eugen Stan
> http://ieugen.blogspot.com/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message