virajjasani commented on a change in pull request #1724:
URL: https://github.com/apache/hbase/pull/1724#discussion_r426269014



##########
File path: 
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestTableSnapshotScanner.java
##########
@@ -190,6 +195,36 @@ public void testNoDuplicateResultsWhenSplitting() throws 
Exception {
     }
   }
 
+
+  @Test
+  public void testScanLimit() throws Exception {
+    setupCluster();
+    final TableName tableName = TableName.valueOf(name.getMethodName());
+    final String snapshotName = tableName + "Snapshot";
+    try {
+      createTableAndSnapshot(UTIL, tableName, snapshotName, 50);
+      Path restoreDir = UTIL.getDataTestDirOnTestFS(snapshotName);
+      Scan scan = new Scan().withStartRow(bbb).setLimit(100); // limit the scan
+
+      TableSnapshotScanner scanner =
+          new TableSnapshotScanner(UTIL.getConfiguration(), restoreDir, 
snapshotName, scan);
+      int count = 0;
+      while (true) {
+        Result result = scanner.next();
+        if (result == null) {
+          break;
+        }
+        count++;
+      }
+      Assert.assertEquals(100, count);
+      scanner.close();

Review comment:
       Can we move `scanner.close()` in finally? We can definte 
`TableSnapshotScanner scanner=null` outside of try {}, and in finally, we can 
check if scanner is not null, then close it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to