From ce09411591293861b065d1838206ad4d547710b3 Mon Sep 17 00:00:00 2001 From: Doug Meil Date: Wed, 11 Jan 2012 21:54:23 +0000 Subject: [PATCH] hbase-5180 book.xml - the scanner example wasn't closing the ResultScanner. That's not good practice. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1230271 13f79535-47bb-0310-9956-ffa450edef68 --- src/docbkx/book.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/docbkx/book.xml b/src/docbkx/book.xml index c67ca06da66..4256a6051da 100644 --- a/src/docbkx/book.xml +++ b/src/docbkx/book.xml @@ -263,8 +263,12 @@ Scan scan = new Scan(); scan.addColumn(Bytes.toBytes("cf"),Bytes.toBytes("attr")); scan.setStartRow( Bytes.toBytes("row")); // start key is inclusive scan.setStopRow( Bytes.toBytes("row" + (char)0)); // stop key is exclusive -for(Result result : htable.getScanner(scan)) { - // process Result instance +ResultScanner rs = htable.getScanner(scan); +try { + for (Result r = rs.next(); r != null; r = rs.next()) { + // process result... +} finally { + rs.close(); // always close the ResultScanner! }