You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2017/12/20 15:07:20 UTC

[GitHub] milleruntime closed pull request #341: ACCUMULO-3902 Ensure [Batch]Scanners are closed in ITs

milleruntime closed pull request #341: ACCUMULO-3902 Ensure [Batch]Scanners are closed in ITs
URL: https://github.com/apache/accumulo/pull/341
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
index c99ba98ef2..be4af24fd0 100644
--- a/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
@@ -367,21 +367,20 @@ public void testDataOperationsAudits() throws AccumuloSecurityException, Accumul
 
     // Start testing activities here
     // A regular scan
-    Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, auths);
-    for (Map.Entry<Key,Value> entry : scanner) {
-      System.out.println("Scanner row: " + entry.getKey() + " " + entry.getValue());
+    try (Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, auths)) {
+      for (Map.Entry<Key,Value> entry : scanner) {
+        System.out.println("Scanner row: " + entry.getKey() + " " + entry.getValue());
+      }
     }
-    scanner.close();
 
     // A batch scan
-    BatchScanner bs = auditConnector.createBatchScanner(OLD_TEST_TABLE_NAME, auths, 1);
-    bs.fetchColumn(new Text("cf1"), new Text("cq1"));
-    bs.setRanges(Arrays.asList(new Range("myRow", "myRow~")));
-
-    for (Map.Entry<Key,Value> entry : bs) {
-      System.out.println("BatchScanner row: " + entry.getKey() + " " + entry.getValue());
+    try (BatchScanner bs = auditConnector.createBatchScanner(OLD_TEST_TABLE_NAME, auths, 1)) {
+      bs.fetchColumn(new Text("cf1"), new Text("cq1"));
+      bs.setRanges(Arrays.asList(new Range("myRow", "myRow~")));
+      for (Map.Entry<Key,Value> entry : bs) {
+        System.out.println("BatchScanner row: " + entry.getKey() + " " + entry.getValue());
+      }
     }
-    bs.close();
 
     // Delete some data.
     auditConnector.tableOperations().deleteRows(OLD_TEST_TABLE_NAME, new Text("myRow"), new Text("myRow~"));
@@ -425,8 +424,7 @@ public void testDeniedAudits() throws AccumuloSecurityException, AccumuloExcepti
     try {
       auditConnector.tableOperations().offline(OLD_TEST_TABLE_NAME);
     } catch (AccumuloSecurityException ex) {}
-    try {
-      Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, auths);
+    try (Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, auths)) {
       scanner.iterator().next().getKey();
     } catch (RuntimeException ex) {}
     try {
diff --git a/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java b/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java
index e997d8bc2c..6c8fde234d 100644
--- a/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/BadDeleteMarkersCreatedIT.java
@@ -163,16 +163,16 @@ public void test() throws Exception {
     sleepUninterruptibly(timeoutFactor * 15, TimeUnit.SECONDS);
     log.info("Verifying that delete markers were deleted");
     // look for delete markers
-    Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(MetadataSchema.DeletesSection.getRange());
-    for (Entry<Key,Value> entry : scanner) {
-      String row = entry.getKey().getRow().toString();
-      if (!row.contains("/" + tableId + "/")) {
-        log.info("Ignoring delete entry for a table other than the one we deleted");
-        continue;
+    try (Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(MetadataSchema.DeletesSection.getRange());
+      for (Entry<Key,Value> entry : scanner) {
+        String row = entry.getKey().getRow().toString();
+        if (!row.contains("/" + tableId + "/")) {
+          log.info("Ignoring delete entry for a table other than the one we deleted");
+          continue;
+        }
+        Assert.fail("Delete entry should have been deleted by the garbage collector: " + entry.getKey().getRow().toString());
       }
-      Assert.fail("Delete entry should have been deleted by the garbage collector: " + entry.getKey().getRow().toString());
     }
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/BalanceFasterIT.java b/test/src/main/java/org/apache/accumulo/test/BalanceFasterIT.java
index 70e94f761f..e3ed95a45e 100644
--- a/test/src/main/java/org/apache/accumulo/test/BalanceFasterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/BalanceFasterIT.java
@@ -74,28 +74,32 @@ public void test() throws Exception {
     // give a short wait for balancing
     sleepUninterruptibly(10, TimeUnit.SECONDS);
     // find out where the tabets are
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
-    s.setRange(MetadataSchema.TabletsSection.getRange());
-    Map<String,Integer> counts = new HashMap<>();
-    while (true) {
-      int total = 0;
-      counts.clear();
-      for (Entry<Key,Value> kv : s) {
-        String host = kv.getValue().toString();
-        if (!counts.containsKey(host))
-          counts.put(host, 0);
-        counts.put(host, counts.get(host) + 1);
-        total++;
+    Iterator<Integer> i;
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
+      s.setRange(MetadataSchema.TabletsSection.getRange());
+      Map<String,Integer> counts = new HashMap<>();
+      while (true) {
+        int total = 0;
+        counts.clear();
+        for (Entry<Key,Value> kv : s) {
+          String host = kv.getValue().toString();
+          if (!counts.containsKey(host))
+            counts.put(host, 0);
+          counts.put(host, counts.get(host) + 1);
+          total++;
+        }
+        // are enough tablets online?
+        if (total > 1000)
+          break;
       }
-      // are enough tablets online?
-      if (total > 1000)
-        break;
+
+      // should be on all three servers
+      assertTrue(counts.size() == 3);
+      // and distributed evenly
+      i = counts.values().iterator();
     }
-    // should be on all three servers
-    assertTrue(counts.size() == 3);
-    // and distributed evenly
-    Iterator<Integer> i = counts.values().iterator();
+
     int a = i.next();
     int b = i.next();
     int c = i.next();
@@ -103,5 +107,4 @@ public void test() throws Exception {
     assertTrue(Math.abs(a - c) < 3);
     assertTrue(a > 330);
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/BatchWriterInTabletServerIT.java b/test/src/main/java/org/apache/accumulo/test/BatchWriterInTabletServerIT.java
index b9560b6c1a..f1ecda1a6f 100644
--- a/test/src/main/java/org/apache/accumulo/test/BatchWriterInTabletServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/BatchWriterInTabletServerIT.java
@@ -104,24 +104,32 @@ private void test(String t1, String t2, Connector c, IteratorSetting itset, int
     c.tableOperations().attachIterator(t2, summer);
 
     Map.Entry<Key,Value> actual;
-    // Scan t1 with an iterator that writes to table t2
-    Scanner scanner = c.createScanner(t1, Authorizations.EMPTY);
-    scanner.addScanIterator(itset);
-    actual = Iterators.getOnlyElement(scanner.iterator());
-    Assert.assertTrue(actual.getKey().equals(k, PartialKey.ROW_COLFAM_COLQUAL));
-    Assert.assertEquals(BatchWriterIterator.SUCCESS_VALUE, actual.getValue());
-    scanner.close();
+    Scanner scanner = null;
+    try {
+      // Scan t1 with an iterator that writes to table t2
+      scanner = c.createScanner(t1, Authorizations.EMPTY);
+      scanner.addScanIterator(itset);
+      actual = Iterators.getOnlyElement(scanner.iterator());
+      Assert.assertTrue(actual.getKey().equals(k, PartialKey.ROW_COLFAM_COLQUAL));
+      Assert.assertEquals(BatchWriterIterator.SUCCESS_VALUE, actual.getValue());
+    } finally {
+      if (scanner != null) {scanner.close();}
+    }
 
-    // ensure entries correctly wrote to table t2
-    scanner = c.createScanner(t2, Authorizations.EMPTY);
-    actual = Iterators.getOnlyElement(scanner.iterator());
-    log.debug("t2 entry is " + actual.getKey().toStringNoTime() + " -> " + actual.getValue());
-    Assert.assertTrue(actual.getKey().equals(k, PartialKey.ROW_COLFAM_COLQUAL));
-    Assert.assertEquals(numEntriesToWritePerEntry, Integer.parseInt(actual.getValue().toString()));
-    scanner.close();
+    try {
+      // ensure entries correctly wrote to table t2
+      scanner = c.createScanner(t2, Authorizations.EMPTY);
+      actual = Iterators.getOnlyElement(scanner.iterator());
+      log.debug("t2 entry is " + actual.getKey().toStringNoTime() + " -> " + actual.getValue());
+      Assert.assertTrue(actual.getKey().equals(k, PartialKey.ROW_COLFAM_COLQUAL));
+      Assert.assertEquals(numEntriesToWritePerEntry, Integer.parseInt(actual.getValue().toString()));
+    } finally {
+      if (scanner != null) {
+        scanner.close();
+      }
+    }
 
     c.tableOperations().delete(t1);
     c.tableOperations().delete(t2);
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/CleanWalIT.java b/test/src/main/java/org/apache/accumulo/test/CleanWalIT.java
index bcefcf8d1d..dac2caf703 100644
--- a/test/src/main/java/org/apache/accumulo/test/CleanWalIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/CleanWalIT.java
@@ -128,20 +128,21 @@ public void test() throws Exception {
   }
 
   private int countLogs(String tableName, Connector conn) throws TableNotFoundException {
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.fetchColumnFamily(MetadataSchema.TabletsSection.LogColumnFamily.NAME);
-    scanner.setRange(MetadataSchema.TabletsSection.getRange());
     int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      log.debug("Saw {}={}", entry.getKey(), entry.getValue());
-      count++;
+    try (Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.fetchColumnFamily(MetadataSchema.TabletsSection.LogColumnFamily.NAME);
+      scanner.setRange(MetadataSchema.TabletsSection.getRange());
+      for (Entry<Key,Value> entry : scanner) {
+        log.debug("Saw {}={}", entry.getKey(), entry.getValue());
+        count++;
+      }
     }
     return count;
   }
 
   int count(String tableName, Connector conn) throws Exception {
-    Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
-    return Iterators.size(s.iterator());
+    try (Scanner s = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      return Iterators.size(s.iterator());
+    }
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
index 180eed1aa2..ceef42585c 100644
--- a/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ClientSideIteratorIT.java
@@ -99,12 +99,12 @@ public void testIntersect() throws Exception {
     bw.addMutation(m);
     bw.flush();
 
-    final ClientSideIteratorScanner csis = new ClientSideIteratorScanner(conn.createScanner(tableName, new Authorizations()));
     final IteratorSetting si = new IteratorSetting(10, tableName, IntersectingIterator.class);
-    IntersectingIterator.setColumnFamilies(si, new Text[] {new Text("bar"), new Text("foo")});
-    csis.addScanIterator(si);
-
-    checkResults(csis, resultSet3, PartialKey.ROW_COLFAM_COLQUAL);
+    try (ClientSideIteratorScanner csis = new ClientSideIteratorScanner(conn.createScanner(tableName, new Authorizations()))) {
+      IntersectingIterator.setColumnFamilies(si, new Text[] {new Text("bar"), new Text("foo")});
+      csis.addScanIterator(si);
+      checkResults(csis, resultSet3, PartialKey.ROW_COLFAM_COLQUAL);
+    }
   }
 
   @Test
@@ -125,20 +125,25 @@ public void testVersioning() throws Exception {
     bw.addMutation(m);
     bw.flush();
 
-    final Scanner scanner = conn.createScanner(tableName, new Authorizations());
-
-    final ClientSideIteratorScanner csis = new ClientSideIteratorScanner(scanner);
-    final IteratorSetting si = new IteratorSetting(10, "localvers", VersioningIterator.class);
-    si.addOption("maxVersions", "2");
-    csis.addScanIterator(si);
-
-    checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
-    checkResults(scanner, resultSet2, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
-
-    csis.fetchColumnFamily(new Text("colf"));
-    checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
-    csis.clearColumns();
-    csis.fetchColumnFamily(new Text("none"));
-    assertFalse(csis.iterator().hasNext());
+    ClientSideIteratorScanner csis = null;
+    try (Scanner scanner = conn.createScanner(tableName, new Authorizations())) {
+      csis = new ClientSideIteratorScanner(scanner);
+      final IteratorSetting si = new IteratorSetting(10, "localvers", VersioningIterator.class);
+      si.addOption("maxVersions", "2");
+      csis.addScanIterator(si);
+
+      checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
+      checkResults(scanner, resultSet2, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
+
+      csis.fetchColumnFamily(new Text("colf"));
+      checkResults(csis, resultSet1, PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME);
+      csis.clearColumns();
+      csis.fetchColumnFamily(new Text("none"));
+      assertFalse(csis.iterator().hasNext());
+    } finally {
+      if (csis != null) {
+        csis.close();
+      }
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/CloneIT.java b/test/src/main/java/org/apache/accumulo/test/CloneIT.java
index 409487f014..64a93fc0e2 100644
--- a/test/src/main/java/org/apache/accumulo/test/CloneIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/CloneIT.java
@@ -111,19 +111,17 @@ public void testFilesChange() throws Exception {
 
     assertEquals(0, rc);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
-
     HashSet<String> files = new HashSet<>();
 
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME))
-        files.add(entry.getKey().getColumnQualifier().toString());
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME))
+          files.add(entry.getKey().getColumnQualifier().toString());
+      }
     }
-
     assertEquals(1, files.size());
     assertTrue(files.contains("../0/default_tablet/1_0.rf"));
-
   }
 
   // test split where files of children are the same
@@ -152,19 +150,18 @@ public void testSplit1() throws Exception {
 
     assertEquals(0, rc);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
-
     HashSet<String> files = new HashSet<>();
-
     int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
+
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+          files.add(entry.getKey().getColumnQualifier().toString());
+          count++;
+        }
       }
     }
-
     assertEquals(1, count);
     assertEquals(1, files.size());
     assertTrue(files.contains("../0/default_tablet/0_0.rf"));
@@ -202,20 +199,18 @@ public void testSplit2() throws Exception {
 
     assertEquals(0, rc);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
-
     HashSet<String> files = new HashSet<>();
-
     int count = 0;
 
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+          files.add(entry.getKey().getColumnQualifier().toString());
+          count++;
+        }
       }
     }
-
     assertEquals(1, files.size());
     assertEquals(2, count);
     assertTrue(files.contains("../0/default_tablet/1_0.rf"));
@@ -272,19 +267,18 @@ public void testSplit3() throws Exception {
 
     assertEquals(0, rc);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
-
     HashSet<String> files = new HashSet<>();
-
     int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
+
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+          files.add(entry.getKey().getColumnQualifier().toString());
+          count++;
+        }
       }
     }
-
     assertEquals(2, count);
     assertEquals(2, files.size());
     assertTrue(files.contains("../0/d1/file1"));
@@ -337,19 +331,18 @@ public void testClonedMarker() throws Exception {
 
     assertEquals(0, rc);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
-
     HashSet<String> files = new HashSet<>();
-
     int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
-        files.add(entry.getKey().getColumnQualifier().toString());
-        count++;
+
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new KeyExtent(Table.ID.of("1"), null, null).toMetadataRange());
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) {
+          files.add(entry.getKey().getColumnQualifier().toString());
+          count++;
+        }
       }
     }
-
     assertEquals(3, count);
     assertEquals(3, files.size());
     assertTrue(files.contains("../0/d1/file1"));
diff --git a/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java b/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
index 45ed2f3e13..a1377f9f0f 100644
--- a/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ConditionalWriterIT.java
@@ -153,7 +153,8 @@ public void testBasic() throws Exception {
 
     conn.tableOperations().create(tableName);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig())) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig());
+        Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
 
       // mutation conditional on column tx:seq not existing
       ConditionalMutation cm0 = new ConditionalMutation("99006", new Condition("tx", "seq"));
@@ -194,7 +195,6 @@ public void testBasic() throws Exception {
       Assert.assertEquals(Status.REJECTED, cw.write(cm5).getStatus());
 
       // ensure rejected mutations did not write
-      Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
       scanner.fetchColumn(new Text("name"), new Text("last"));
       scanner.setRange(new Range("99006"));
       Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
@@ -255,7 +255,8 @@ public void testFields() throws Exception {
 
     conn.tableOperations().create(tableName);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(auths))) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(auths));
+        Scanner scanner = conn.createScanner(tableName, auths)) {
 
       ColumnVisibility cva = new ColumnVisibility("A");
       ColumnVisibility cvb = new ColumnVisibility("B");
@@ -266,7 +267,6 @@ public void testFields() throws Exception {
       cm0.put("tx", "seq", cva, "1");
       Assert.assertEquals(Status.ACCEPTED, cw.write(cm0).getStatus());
 
-      Scanner scanner = conn.createScanner(tableName, auths);
       scanner.setRange(new Range("99006"));
       // TODO verify all columns
       scanner.fetchColumn(new Text("tx"), new Text("seq"));
@@ -434,9 +434,8 @@ public void testConstraints() throws Exception {
     conn.tableOperations().addConstraint(tableName, AlphaNumKeyConstraint.class.getName());
     conn.tableOperations().clone(tableName, tableName + "_clone", true, new HashMap<String,String>(), new HashSet<String>());
 
-    Scanner scanner = conn.createScanner(tableName + "_clone", new Authorizations());
-
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName + "_clone", new ConditionalWriterConfig())) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName + "_clone", new ConditionalWriterConfig());
+        Scanner scanner = conn.createScanner(tableName + "_clone", new Authorizations())) {
 
       ConditionalMutation cm0 = new ConditionalMutation("99006+", new Condition("tx", "seq"));
       cm0.put("tx", "seq", "1");
@@ -491,62 +490,69 @@ public void testIterators() throws Exception {
     IteratorSetting iterConfig3 = new IteratorSetting(5, VersioningIterator.class);
     VersioningIterator.setMaxVersions(iterConfig3, 1);
 
-    Scanner scanner = conn.createScanner(tableName, new Authorizations());
-    scanner.addScanIterator(iterConfig);
-    scanner.setRange(new Range("ACCUMULO-1000"));
-    scanner.fetchColumn(new Text("count"), new Text("comments"));
+    Scanner scanner = null;
+    try {
+      scanner = conn.createScanner(tableName, new Authorizations());
+      scanner.addScanIterator(iterConfig);
+      scanner.setRange(new Range("ACCUMULO-1000"));
+      scanner.fetchColumn(new Text("count"), new Text("comments"));
 
-    Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
-    Assert.assertEquals("3", entry.getValue().toString());
+      Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
+      Assert.assertEquals("3", entry.getValue().toString());
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig())) {
+      try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig())) {
 
-      ConditionalMutation cm0 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setValue("3"));
-      cm0.put("count", "comments", "1");
-      Assert.assertEquals(Status.REJECTED, cw.write(cm0).getStatus());
-      entry = Iterables.getOnlyElement(scanner);
-      Assert.assertEquals("3", entry.getValue().toString());
+        ConditionalMutation cm0 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setValue("3"));
+        cm0.put("count", "comments", "1");
+        Assert.assertEquals(Status.REJECTED, cw.write(cm0).getStatus());
+        entry = Iterables.getOnlyElement(scanner);
+        Assert.assertEquals("3", entry.getValue().toString());
 
-      ConditionalMutation cm1 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setIterators(iterConfig).setValue("3"));
-      cm1.put("count", "comments", "1");
-      Assert.assertEquals(Status.ACCEPTED, cw.write(cm1).getStatus());
-      entry = Iterables.getOnlyElement(scanner);
-      Assert.assertEquals("4", entry.getValue().toString());
+        ConditionalMutation cm1 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setIterators(iterConfig).setValue("3"));
+        cm1.put("count", "comments", "1");
+        Assert.assertEquals(Status.ACCEPTED, cw.write(cm1).getStatus());
+        entry = Iterables.getOnlyElement(scanner);
+        Assert.assertEquals("4", entry.getValue().toString());
 
-      ConditionalMutation cm2 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setValue("4"));
-      cm2.put("count", "comments", "1");
-      Assert.assertEquals(Status.REJECTED, cw.write(cm1).getStatus());
-      entry = Iterables.getOnlyElement(scanner);
-      Assert.assertEquals("4", entry.getValue().toString());
+        ConditionalMutation cm2 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setValue("4"));
+        cm2.put("count", "comments", "1");
+        Assert.assertEquals(Status.REJECTED, cw.write(cm1).getStatus());
+        entry = Iterables.getOnlyElement(scanner);
+        Assert.assertEquals("4", entry.getValue().toString());
 
-      // run test with multiple iterators passed in same batch and condition with two iterators
+        // run test with multiple iterators passed in same batch and condition with two iterators
 
-      ConditionalMutation cm3 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setIterators(iterConfig).setValue("4"));
-      cm3.put("count", "comments", "1");
+        ConditionalMutation cm3 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setIterators(iterConfig).setValue("4"));
+        cm3.put("count", "comments", "1");
 
-      ConditionalMutation cm4 = new ConditionalMutation("ACCUMULO-1001", new Condition("count2", "comments").setIterators(iterConfig2).setValue("2"));
-      cm4.put("count2", "comments", "1");
+        ConditionalMutation cm4 = new ConditionalMutation("ACCUMULO-1001", new Condition("count2", "comments").setIterators(iterConfig2).setValue("2"));
+        cm4.put("count2", "comments", "1");
 
-      ConditionalMutation cm5 = new ConditionalMutation("ACCUMULO-1002", new Condition("count2", "comments").setIterators(iterConfig2, iterConfig3).setValue(
-          "2"));
-      cm5.put("count2", "comments", "1");
+        ConditionalMutation cm5 = new ConditionalMutation("ACCUMULO-1002", new Condition("count2", "comments").setIterators(iterConfig2, iterConfig3).setValue(
+            "2"));
+        cm5.put("count2", "comments", "1");
 
-      Iterator<Result> results = cw.write(Arrays.asList(cm3, cm4, cm5).iterator());
-      Map<String,Status> actual = new HashMap<>();
+        Iterator<Result> results = cw.write(Arrays.asList(cm3, cm4, cm5).iterator());
+        Map<String,Status> actual = new HashMap<>();
 
-      while (results.hasNext()) {
-        Result result = results.next();
-        String k = new String(result.getMutation().getRow());
-        Assert.assertFalse("Did not expect to see multiple resultus for the row: " + k, actual.containsKey(k));
-        actual.put(k, result.getStatus());
-      }
+        while (results.hasNext()) {
+          Result result = results.next();
+          String k = new String(result.getMutation().getRow());
+          Assert.assertFalse("Did not expect to see multiple resultus for the row: " + k, actual.containsKey(k));
+          actual.put(k, result.getStatus());
+        }
 
-      Map<String,Status> expected = new HashMap<>();
-      expected.put("ACCUMULO-1000", Status.ACCEPTED);
-      expected.put("ACCUMULO-1001", Status.ACCEPTED);
-      expected.put("ACCUMULO-1002", Status.REJECTED);
+        Map<String,Status> expected = new HashMap<>();
+        expected.put("ACCUMULO-1000", Status.ACCEPTED);
+        expected.put("ACCUMULO-1001", Status.ACCEPTED);
+        expected.put("ACCUMULO-1002", Status.REJECTED);
 
-      Assert.assertEquals(expected, actual);
+        Assert.assertEquals(expected, actual);
+      }
+    } finally {
+      if (scanner != null) {
+        scanner.close();
+      }
     }
   }
 
@@ -622,13 +628,13 @@ public void testTableAndConditionIterators() throws Exception {
     conn.tableOperations().offline(tableName, true);
     conn.tableOperations().online(tableName, true);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig())) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig());
+        Scanner scanner = conn.createScanner(tableName, new Authorizations())) {
 
       ConditionalMutation cm6 = new ConditionalMutation("ACCUMULO-1000", new Condition("count", "comments").setValue("8"));
       cm6.put("count", "comments", "7");
       Assert.assertEquals(Status.ACCEPTED, cw.write(cm6).getStatus());
 
-      Scanner scanner = conn.createScanner(tableName, new Authorizations());
       scanner.setRange(new Range("ACCUMULO-1000"));
       scanner.fetchColumn(new Text("count"), new Text("comments"));
 
@@ -672,7 +678,6 @@ public void testTableAndConditionIterators() throws Exception {
       expected.put("ACCUMULO-1000", Status.ACCEPTED);
       expected.put("ACCUMULO-1001", Status.ACCEPTED);
       expected.put("ACCUMULO-1002", Status.REJECTED);
-
       Assert.assertEquals(expected, actual);
     }
   }
@@ -709,7 +714,8 @@ public void testBatch() throws Exception {
     cm2.put("tx", "seq", cvab, "1");
     mutations.add(cm2);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")))) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")));
+        Scanner scanner = conn.createScanner(tableName, new Authorizations("A"))) {
       Iterator<Result> results = cw.write(mutations.iterator());
       int count = 0;
       while (results.hasNext()) {
@@ -720,7 +726,6 @@ public void testBatch() throws Exception {
 
       Assert.assertEquals(3, count);
 
-      Scanner scanner = conn.createScanner(tableName, new Authorizations("A"));
       scanner.fetchColumn(new Text("tx"), new Text("seq"));
 
       for (String row : new String[] {"99006", "59056", "19059"}) {
@@ -907,7 +912,8 @@ public void testBatchErrors() throws Exception {
     cm3.put("tx", "seq", cvaob, "2");
     mutations.add(cm3);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")))) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(tableName, new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")));
+        Scanner scanner = conn.createScanner(tableName, new Authorizations("A"))) {
       Iterator<Result> results = cw.write(mutations.iterator());
       HashSet<String> rows = new HashSet<>();
       while (results.hasNext()) {
@@ -927,9 +933,7 @@ public void testBatchErrors() throws Exception {
 
       Assert.assertEquals(4, rows.size());
 
-      Scanner scanner = conn.createScanner(tableName, new Authorizations("A"));
       scanner.fetchColumn(new Text("tx"), new Text("seq"));
-
       Entry<Key,Value> entry = Iterables.getOnlyElement(scanner);
       Assert.assertEquals("1", entry.getValue().toString());
     }
@@ -1178,7 +1182,6 @@ public void testThreads() throws Exception {
     }
 
     try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
-
       RowIterator rowIter = new RowIterator(scanner);
 
       while (rowIter.hasNext()) {
@@ -1267,7 +1270,8 @@ public void testTimeout() throws Exception {
 
     conn.tableOperations().create(table);
 
-    try (ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig().setTimeout(3, TimeUnit.SECONDS))) {
+    try (ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig().setTimeout(3, TimeUnit.SECONDS));
+        Scanner scanner = conn.createScanner(table, Authorizations.EMPTY)) {
 
       ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
       cm1.put("tx", "seq", "1");
@@ -1284,8 +1288,6 @@ public void testTimeout() throws Exception {
 
       Assert.assertEquals(cw.write(cm2).getStatus(), Status.UNKNOWN);
 
-      Scanner scanner = conn.createScanner(table, Authorizations.EMPTY);
-
       for (Entry<Key,Value> entry : scanner) {
         String cf = entry.getKey().getColumnFamilyData().toString();
         String cq = entry.getKey().getColumnQualifierData().toString();
@@ -1445,44 +1447,45 @@ public void testTrace() throws Exception {
       root.stop();
     }
 
-    final Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY);
-    scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
-    loop: while (true) {
-      final StringBuilder finalBuffer = new StringBuilder();
-      int traceCount = TraceDump.printTrace(scanner, new Printer() {
-        @Override
-        public void print(final String line) {
-          try {
-            finalBuffer.append(line).append("\n");
-          } catch (Exception ex) {
-            throw new RuntimeException(ex);
+    try (Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY)) {
+      scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
+      loop:
+      while (true) {
+        final StringBuilder finalBuffer = new StringBuilder();
+        int traceCount = TraceDump.printTrace(scanner, new Printer() {
+          @Override public void print(final String line) {
+            try {
+              finalBuffer.append(line).append("\n");
+            } catch (Exception ex) {
+              throw new RuntimeException(ex);
+            }
           }
-        }
-      });
-      String traceOutput = finalBuffer.toString();
-      log.info("Trace output:" + traceOutput);
-      if (traceCount > 0) {
-        int lastPos = 0;
-        for (String part : "traceTest, startScan,startConditionalUpdate,conditionalUpdate,Check conditions,apply conditional mutations".split(",")) {
-          log.info("Looking in trace output for '" + part + "'");
-          int pos = traceOutput.indexOf(part);
-          if (-1 == pos) {
-            log.info("Trace output doesn't contain '" + part + "'");
-            Thread.sleep(1000);
-            break loop;
+        });
+        String traceOutput = finalBuffer.toString();
+        log.info("Trace output:" + traceOutput);
+        if (traceCount > 0) {
+          int lastPos = 0;
+          for (String part : "traceTest, startScan,startConditionalUpdate,conditionalUpdate,Check conditions,apply conditional mutations".split(",")) {
+            log.info("Looking in trace output for '" + part + "'");
+            int pos = traceOutput.indexOf(part);
+            if (-1 == pos) {
+              log.info("Trace output doesn't contain '" + part + "'");
+              Thread.sleep(1000);
+              break loop;
+            }
+            assertTrue("Did not find '" + part + "' in output", pos > 0);
+            assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
+            lastPos = pos;
           }
-          assertTrue("Did not find '" + part + "' in output", pos > 0);
-          assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
-          lastPos = pos;
+          break;
+        } else {
+          log.info("Ignoring trace output as traceCount not greater than zero: " + traceCount);
+          Thread.sleep(1000);
         }
-        break;
-      } else {
-        log.info("Ignoring trace output as traceCount not greater than zero: " + traceCount);
-        Thread.sleep(1000);
       }
-    }
-    if (tracer != null) {
-      tracer.destroy();
+      if (tracer != null) {
+        tracer.destroy();
+      }
     }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java b/test/src/main/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java
index 20979af8e5..b321ba5e05 100644
--- a/test/src/main/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ConfigurableMajorCompactionIT.java
@@ -101,10 +101,12 @@ public void test() throws Exception {
   }
 
   private int countFiles(Connector conn) throws Exception {
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange());
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    return Iterators.size(s.iterator());
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(MetadataSchema.TabletsSection.getRange());
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      s.close();
+      return Iterators.size(s.iterator());
+    }
   }
 
   private void writeFile(Connector conn, String tableName) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java b/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
index 7fd2dd1fa5..758ff8b03c 100644
--- a/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/CreateTableWithNewTableConfigIT.java
@@ -87,16 +87,17 @@ public int compareProperties(Connector connector, String tableNameOrig, String t
   }
 
   public boolean checkTimeType(Connector connector, String tableName, TimeType expectedTimeType) throws TableNotFoundException {
-    final Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    String tableID = connector.tableOperations().tableIdMap().get(tableName) + "<";
-    for (Entry<Key,Value> entry : scanner) {
-      Key k = entry.getKey();
-
-      if (k.getRow().toString().equals(tableID) && k.getColumnQualifier().toString().equals(ServerColumnFamily.TIME_COLUMN.getColumnQualifier().toString())) {
-        if (expectedTimeType == TimeType.MILLIS && entry.getValue().toString().charAt(0) == 'M')
-          return true;
-        if (expectedTimeType == TimeType.LOGICAL && entry.getValue().toString().charAt(0) == 'L')
-          return true;
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      String tableID = connector.tableOperations().tableIdMap().get(tableName) + "<";
+      for (Entry<Key,Value> entry : scanner) {
+        Key k = entry.getKey();
+
+        if (k.getRow().toString().equals(tableID) && k.getColumnQualifier().toString().equals(ServerColumnFamily.TIME_COLUMN.getColumnQualifier().toString())) {
+          if (expectedTimeType == TimeType.MILLIS && entry.getValue().toString().charAt(0) == 'M')
+            return true;
+          if (expectedTimeType == TimeType.LOGICAL && entry.getValue().toString().charAt(0) == 'L')
+            return true;
+        }
       }
     }
     return false;
diff --git a/test/src/main/java/org/apache/accumulo/test/ExistingMacIT.java b/test/src/main/java/org/apache/accumulo/test/ExistingMacIT.java
index 90fb828b8a..7c409b4f0c 100644
--- a/test/src/main/java/org/apache/accumulo/test/ExistingMacIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ExistingMacIT.java
@@ -136,15 +136,14 @@ public void testExistingInstance() throws Exception {
 
     conn = accumulo2.getConnector("root", new PasswordToken(ROOT_PASSWORD));
 
-    Scanner scanner = conn.createScanner("table1", Authorizations.EMPTY);
-
-    int sum = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      sum += Integer.parseInt(entry.getValue().toString());
+    try (Scanner scanner = conn.createScanner("table1", Authorizations.EMPTY)) {
+      int sum = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        sum += Integer.parseInt(entry.getValue().toString());
+      }
+      Assert.assertEquals(6569, sum);
     }
 
-    Assert.assertEquals(6569, sum);
-
     accumulo2.stop();
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/FileArchiveIT.java b/test/src/main/java/org/apache/accumulo/test/FileArchiveIT.java
index 11464b4ee5..e2e845db0b 100644
--- a/test/src/main/java/org/apache/accumulo/test/FileArchiveIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/FileArchiveIT.java
@@ -77,43 +77,44 @@ public void testUnusuedFilesAreArchived() throws Exception {
     // Compact memory to disk
     conn.tableOperations().compact(tableName, null, null, true, true);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    final String file = entry.getKey().getColumnQualifier().toString();
-    final Path p = new Path(file);
-
-    // Then force another to make an unreferenced file
-    conn.tableOperations().compact(tableName, null, null, true, true);
-
-    log.info("File for table: {}", file);
-
-    FileSystem fs = getCluster().getFileSystem();
-    int i = 0;
-    while (fs.exists(p)) {
-      i++;
-      Thread.sleep(1000);
-      if (0 == i % 10) {
-        log.info("Waited {} iterations, file still exists", i);
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      final String file = entry.getKey().getColumnQualifier().toString();
+      final Path p = new Path(file);
+
+      // Then force another to make an unreferenced file
+      conn.tableOperations().compact(tableName, null, null, true, true);
+
+      log.info("File for table: {}", file);
+
+      FileSystem fs = getCluster().getFileSystem();
+      int i = 0;
+      while (fs.exists(p)) {
+        i++;
+        Thread.sleep(1000);
+        if (0 == i % 10) {
+          log.info("Waited {} iterations, file still exists", i);
+        }
       }
-    }
 
-    log.info("File was removed");
+      log.info("File was removed");
 
-    String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
+      String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
 
-    log.info("File relative to accumulo dir: {}", filePath);
+      log.info("File relative to accumulo dir: {}", filePath);
 
-    Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
+      Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
 
-    Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
+      Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
 
-    // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
-    Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
+      // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
+      Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
 
-    Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
+      Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
+    }
   }
 
   @Test
@@ -135,42 +136,43 @@ public void testDeletedTableIsArchived() throws Exception {
     // Compact memory to disk
     conn.tableOperations().compact(tableName, null, null, true, true);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
 
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    final String file = entry.getKey().getColumnQualifier().toString();
-    final Path p = new Path(file);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      final String file = entry.getKey().getColumnQualifier().toString();
+      final Path p = new Path(file);
 
-    conn.tableOperations().delete(tableName);
+      conn.tableOperations().delete(tableName);
 
-    log.info("File for table: {}", file);
+      log.info("File for table: {}", file);
 
-    FileSystem fs = getCluster().getFileSystem();
-    int i = 0;
-    while (fs.exists(p)) {
-      i++;
-      Thread.sleep(1000);
-      if (0 == i % 10) {
-        log.info("Waited {} iterations, file still exists", i);
+      FileSystem fs = getCluster().getFileSystem();
+      int i = 0;
+      while (fs.exists(p)) {
+        i++;
+        Thread.sleep(1000);
+        if (0 == i % 10) {
+          log.info("Waited {} iterations, file still exists", i);
+        }
       }
-    }
 
-    log.info("File was removed");
+      log.info("File was removed");
 
-    String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
+      String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
 
-    log.info("File relative to accumulo dir: {}", filePath);
+      log.info("File relative to accumulo dir: {}", filePath);
 
-    Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
+      Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
 
-    Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
+      Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
 
-    // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
-    Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
+      // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
+      Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
 
-    Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
+      Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
+    }
   }
 
   @Test
@@ -192,81 +194,88 @@ public void testUnusuedFilesAndDeletedTable() throws Exception {
     // Compact memory to disk
     conn.tableOperations().compact(tableName, null, null, true, true);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    final String file = entry.getKey().getColumnQualifier().toString();
-    final Path p = new Path(file);
-
-    // Then force another to make an unreferenced file
-    conn.tableOperations().compact(tableName, null, null, true, true);
-
-    log.info("File for table: {}", file);
-
-    FileSystem fs = getCluster().getFileSystem();
-    int i = 0;
-    while (fs.exists(p)) {
-      i++;
-      Thread.sleep(1000);
-      if (0 == i % 10) {
-        log.info("Waited {} iterations, file still exists", i);
+    Scanner s = null;
+    try {
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      final String file = entry.getKey().getColumnQualifier().toString();
+      final Path p = new Path(file);
+
+      // Then force another to make an unreferenced file
+      conn.tableOperations().compact(tableName, null, null, true, true);
+
+      log.info("File for table: {}", file);
+
+      FileSystem fs = getCluster().getFileSystem();
+      int i = 0;
+      while (fs.exists(p)) {
+        i++;
+        Thread.sleep(1000);
+        if (0 == i % 10) {
+          log.info("Waited {} iterations, file still exists", i);
+        }
       }
-    }
 
-    log.info("File was removed");
+      log.info("File was removed");
 
-    String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
+      String filePath = p.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
 
-    log.info("File relative to accumulo dir: {}", filePath);
+      log.info("File relative to accumulo dir: {}", filePath);
 
-    Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
+      Path fileArchiveDir = new Path(getCluster().getConfig().getAccumuloDir().toString(), ServerConstants.FILE_ARCHIVE_DIR);
 
-    Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
+      Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
 
-    // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
-    Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
+      // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
+      Path archivedFile = new Path(fileArchiveDir, filePath.substring(1));
 
-    Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
+      Assert.assertTrue("File doesn't exists in archive directory: " + archivedFile, fs.exists(archivedFile));
 
-    // Offline the table so we can be sure there is a single file
-    conn.tableOperations().offline(tableName, true);
+      // Offline the table so we can be sure there is a single file
+      conn.tableOperations().offline(tableName, true);
 
-    // See that the file in metadata currently is
-    s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      // See that the file in metadata currently is
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.setRange(MetadataSchema.TabletsSection.getRange(tableId));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
 
-    entry = Iterables.getOnlyElement(s);
-    final String finalFile = entry.getKey().getColumnQualifier().toString();
-    final Path finalPath = new Path(finalFile);
+      entry = Iterables.getOnlyElement(s);
+      final String finalFile = entry.getKey().getColumnQualifier().toString();
+      final Path finalPath = new Path(finalFile);
 
-    conn.tableOperations().delete(tableName);
+      conn.tableOperations().delete(tableName);
 
-    log.info("File for table: {}", finalPath);
+      log.info("File for table: {}", finalPath);
 
-    i = 0;
-    while (fs.exists(finalPath)) {
-      i++;
-      Thread.sleep(1000);
-      if (0 == i % 10) {
-        log.info("Waited {} iterations, file still exists", i);
+      i = 0;
+      while (fs.exists(finalPath)) {
+        i++;
+        Thread.sleep(1000);
+        if (0 == i % 10) {
+          log.info("Waited {} iterations, file still exists", i);
+        }
       }
-    }
 
-    log.info("File was removed");
+      log.info("File was removed");
 
-    String finalFilePath = finalPath.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
+      String finalFilePath = finalPath.toUri().getPath().substring(getCluster().getConfig().getAccumuloDir().toString().length());
 
-    log.info("File relative to accumulo dir: {}", finalFilePath);
+      log.info("File relative to accumulo dir: {}", finalFilePath);
 
-    Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
+      Assert.assertTrue("File archive directory didn't exist", fs.exists(fileArchiveDir));
 
-    // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
-    Path finalArchivedFile = new Path(fileArchiveDir, finalFilePath.substring(1));
+      // Remove the leading '/' to make sure Path treats the 2nd arg as a child.
+      Path finalArchivedFile = new Path(fileArchiveDir, finalFilePath.substring(1));
 
-    Assert.assertTrue("File doesn't exists in archive directory: " + finalArchivedFile, fs.exists(finalArchivedFile));
+      s.close();
+      Assert.assertTrue("File doesn't exists in archive directory: " + finalArchivedFile, fs.exists(finalArchivedFile));
+    } finally {
+      if (s != null) {
+        s.close();
+      }
+    }
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java b/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
index 96ab317dde..500c7f958f 100644
--- a/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/FindMaxIT.java
@@ -72,42 +72,43 @@ public void test1() throws Exception {
 
     bw.close();
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
 
-    ArrayList<Text> rows = new ArrayList<>();
+      ArrayList<Text> rows = new ArrayList<>();
 
-    for (Entry<Key,Value> entry : scanner) {
-      rows.add(entry.getKey().getRow());
-    }
+      for (Entry<Key,Value> entry : scanner) {
+        rows.add(entry.getKey().getRow());
+      }
 
-    for (int i = rows.size() - 1; i > 0; i--) {
-      Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), false);
-      assertEquals(rows.get(i - 1), max);
+      for (int i = rows.size() - 1; i > 0; i--) {
+        Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), false);
+        assertEquals(rows.get(i - 1), max);
 
-      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), true, rows.get(i), false);
-      assertEquals(rows.get(i - 1), max);
+        max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), true, rows.get(i), false);
+        assertEquals(rows.get(i - 1), max);
 
-      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), false);
-      assertNull(max);
+        max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), false);
+        assertNull(max);
 
-      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), true);
-      assertEquals(rows.get(i), max);
+        max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, rows.get(i), true);
+        assertEquals(rows.get(i), max);
 
-      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i), true, rows.get(i), true);
-      assertEquals(rows.get(i), max);
+        max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i), true, rows.get(i), true);
+        assertEquals(rows.get(i), max);
 
-      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), true);
-      assertEquals(rows.get(i), max);
+        max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, rows.get(i - 1), false, rows.get(i), true);
+        assertEquals(rows.get(i), max);
 
-    }
+      }
 
-    Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, null, true);
-    assertEquals(rows.get(rows.size() - 1), max);
+      Text max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, null, true);
+      assertEquals(rows.get(rows.size() - 1), max);
 
-    max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), false);
-    assertNull(max);
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), false);
+      assertNull(max);
 
-    max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), true);
-    assertEquals(rows.get(0), max);
+      max = conn.tableOperations().getMaxRow(tableName, Authorizations.EMPTY, null, true, new Text(new byte[] {0}), true);
+      assertEquals(rows.get(0), max);
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java b/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
index 140410bf4e..a21c0d25b5 100644
--- a/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
+++ b/test/src/main/java/org/apache/accumulo/test/IMMLGBenchmark.java
@@ -117,21 +117,21 @@ private static void addStat(Map<String,Stat> stats, String s, long wt) {
   }
 
   private static long scan(Connector conn, ArrayList<byte[]> cfset, String table, boolean cq) throws TableNotFoundException {
-    Scanner scanner = conn.createScanner(table, Authorizations.EMPTY);
+    try (Scanner scanner = conn.createScanner(table, Authorizations.EMPTY)) {
 
-    if (!cq)
-      scanner.fetchColumnFamily(new Text(cfset.get(15)));
-    else
-      scanner.fetchColumn(new Text(cfset.get(15)), new Text(cfset.get(15)));
+      if (!cq)
+        scanner.fetchColumnFamily(new Text(cfset.get(15)));
+      else
+        scanner.fetchColumn(new Text(cfset.get(15)), new Text(cfset.get(15)));
 
-    long t1 = System.currentTimeMillis();
+      long t1 = System.currentTimeMillis();
 
-    Iterators.size(scanner.iterator());
+      Iterators.size(scanner.iterator());
 
-    long t2 = System.currentTimeMillis();
-
-    return t2 - t1;
+      long t2 = System.currentTimeMillis();
 
+      return t2 - t1;
+    }
   }
 
   private static long write(Connector conn, ArrayList<byte[]> cfset, String table) throws TableNotFoundException, MutationsRejectedException {
diff --git a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
index 6815d180b6..5ed57e7990 100644
--- a/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ImportExportIT.java
@@ -139,26 +139,28 @@ public void testExportImportThenScan() throws Exception {
 
     // Get all `file` colfams from the metadata table for the new table
     log.info("Imported into table with ID: {}", tableId);
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.TabletsSection.getRange(org.apache.accumulo.core.client.impl.Table.ID.of(tableId)));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(s);
-
-    // Should find a single entry
-    for (Entry<Key,Value> fileEntry : s) {
-      Key k = fileEntry.getKey();
-      String value = fileEntry.getValue().toString();
-      if (k.getColumnFamily().equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
-        // The file should be an absolute URI (file:///...), not a relative path (/b-000.../I000001.rf)
-        String fileUri = k.getColumnQualifier().toString();
-        Assert.assertFalse("Imported files should have absolute URIs, not relative: " + fileUri, looksLikeRelativePath(fileUri));
-      } else if (k.getColumnFamily().equals(MetadataSchema.TabletsSection.ServerColumnFamily.NAME)) {
-        Assert.assertFalse("Server directory should have absolute URI, not relative: " + value, looksLikeRelativePath(value));
-      } else {
-        Assert.fail("Got expected pair: " + k + "=" + fileEntry.getValue());
+
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(MetadataSchema.TabletsSection.getRange(org.apache.accumulo.core.client.impl.Table.ID.of(tableId)));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(s);
+
+      // Should find a single entry
+      for (Entry<Key,Value> fileEntry : s) {
+        Key k = fileEntry.getKey();
+        String value = fileEntry.getValue().toString();
+        if (k.getColumnFamily().equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
+          // The file should be an absolute URI (file:///...), not a relative path (/b-000.../I000001.rf)
+          String fileUri = k.getColumnQualifier().toString();
+          Assert.assertFalse("Imported files should have absolute URIs, not relative: " + fileUri, looksLikeRelativePath(fileUri));
+        } else if (k.getColumnFamily().equals(MetadataSchema.TabletsSection.ServerColumnFamily.NAME)) {
+          Assert.assertFalse("Server directory should have absolute URI, not relative: " + value, looksLikeRelativePath(value));
+        } else {
+          Assert.fail("Got expected pair: " + k + "=" + fileEntry.getValue());
+        }
       }
-    }
 
+    }
     // Online the original table before we verify equivalence
     conn.tableOperations().online(srcTable, true);
 
diff --git a/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java b/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
index bdf62a14df..0ed9511010 100644
--- a/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
@@ -52,51 +52,52 @@ public void test() throws Exception {
     final String tableName = getUniqueNames(1)[0];
     final Connector conn = getConnector();
     conn.tableOperations().create(tableName);
+
     // make the world's slowest scanner
-    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    final IteratorSetting cfg = new IteratorSetting(100, SlowIterator.class);
-    // Wait long enough to be sure we can catch it, but not indefinitely.
-    SlowIterator.setSeekSleepTime(cfg, 60 * 1000);
-    scanner.addScanIterator(cfg);
-    // create a thread to interrupt the slow scan
-    final Thread scanThread = Thread.currentThread();
-    Thread thread = new Thread() {
-      @Override
-      public void run() {
-        try {
-          // ensure the scan is running: not perfect, the metadata tables could be scanned, too.
-          String tserver = conn.instanceOperations().getTabletServers().iterator().next();
-          do {
-            ArrayList<ActiveScan> scans = new ArrayList<>(conn.instanceOperations().getActiveScans(tserver));
-            Iterator<ActiveScan> iter = scans.iterator();
-            while (iter.hasNext()) {
-              ActiveScan scan = iter.next();
-              // Remove scans not against our table and not owned by us
-              if (!getAdminPrincipal().equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
-                iter.remove();
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      final IteratorSetting cfg = new IteratorSetting(100, SlowIterator.class);
+      // Wait long enough to be sure we can catch it, but not indefinitely.
+      SlowIterator.setSeekSleepTime(cfg, 60 * 1000);
+      scanner.addScanIterator(cfg);
+      // create a thread to interrupt the slow scan
+      final Thread scanThread = Thread.currentThread();
+      Thread thread = new Thread() {
+        @Override public void run() {
+          try {
+            // ensure the scan is running: not perfect, the metadata tables could be scanned, too.
+            String tserver = conn.instanceOperations().getTabletServers().iterator().next();
+            do {
+              ArrayList<ActiveScan> scans = new ArrayList<>(conn.instanceOperations().getActiveScans(tserver));
+              Iterator<ActiveScan> iter = scans.iterator();
+              while (iter.hasNext()) {
+                ActiveScan scan = iter.next();
+                // Remove scans not against our table and not owned by us
+                if (!getAdminPrincipal().equals(scan.getUser()) || !tableName.equals(scan.getTable())) {
+                  iter.remove();
+                }
               }
-            }
 
-            if (!scans.isEmpty()) {
-              // We found our scan
-              break;
-            }
-          } while (true);
-        } catch (Exception e) {
-          e.printStackTrace();
+              if (!scans.isEmpty()) {
+                // We found our scan
+                break;
+              }
+            } while (true);
+          } catch (Exception e) {
+            e.printStackTrace();
+          }
+          // BAM!
+          scanThread.interrupt();
         }
-        // BAM!
-        scanThread.interrupt();
+      };
+      thread.start();
+      try {
+        // Use the scanner, expect problems
+        Iterators.size(scanner.iterator());
+        Assert.fail("Scan should not succeed");
+      } catch (Exception ex) {
+      } finally {
+        thread.join();
       }
-    };
-    thread.start();
-    try {
-      // Use the scanner, expect problems
-      Iterators.size(scanner.iterator());
-      Assert.fail("Scan should not succeed");
-    } catch (Exception ex) {} finally {
-      thread.join();
     }
   }
-
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java b/test/src/main/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java
index 5309525f70..49c3257038 100644
--- a/test/src/main/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/IsolationAndDeepCopyIT.java
@@ -62,15 +62,16 @@ public void testBugFix() throws Exception {
     IteratorSetting iterCfg = new IteratorSetting(30, "ayeaye", IntersectingIterator.class.getName());
     IntersectingIterator.setColumnFamilies(iterCfg, new Text[] {new Text("the"), new Text("hamster")});
 
-    Scanner scanner = conn.createScanner(table, Authorizations.EMPTY);
-    scanner.enableIsolation();
-    scanner.addScanIterator(iterCfg);
-
-    for (int i = 0; i < 100; i++) {
-      Iterator<Entry<Key,Value>> iter = scanner.iterator();
-      Assert.assertTrue(iter.hasNext());
-      Assert.assertEquals("000A", iter.next().getKey().getColumnQualifierData().toString());
-      Assert.assertFalse(iter.hasNext());
+    try (Scanner scanner = conn.createScanner(table, Authorizations.EMPTY)) {
+      scanner.enableIsolation();
+      scanner.addScanIterator(iterCfg);
+
+      for (int i = 0; i < 100; i++) {
+        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+        Assert.assertTrue(iter.hasNext());
+        Assert.assertEquals("000A", iter.next().getKey().getColumnQualifierData().toString());
+        Assert.assertFalse(iter.hasNext());
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/LargeSplitRowIT.java b/test/src/main/java/org/apache/accumulo/test/LargeSplitRowIT.java
index 897ae6ef3e..395c26cddb 100644
--- a/test/src/main/java/org/apache/accumulo/test/LargeSplitRowIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/LargeSplitRowIT.java
@@ -92,15 +92,16 @@ public void userAddedSplit() throws Exception {
 
     // Make sure that the information that was written to the table before we tried to add the split point is still correct
     int counter = 0;
-    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    for (Entry<Key,Value> entry : scanner) {
-      counter++;
-      Key k = entry.getKey();
-      Assert.assertEquals("Row", k.getRow().toString());
-      Assert.assertEquals("cf", k.getColumnFamily().toString());
-      Assert.assertEquals("cq", k.getColumnQualifier().toString());
-      Assert.assertEquals("value", entry.getValue().toString());
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> entry : scanner) {
+        counter++;
+        Key k = entry.getKey();
+        Assert.assertEquals("Row", k.getRow().toString());
+        Assert.assertEquals("cf", k.getColumnFamily().toString());
+        Assert.assertEquals("cq", k.getColumnQualifier().toString());
+        Assert.assertEquals("value", entry.getValue().toString());
 
+      }
     }
     // Make sure there is only one line in the table
     Assert.assertEquals(1, counter);
@@ -142,16 +143,17 @@ public void automaticSplitWith250Same() throws Exception {
 
     // Make sure all the data that was put in the table is still correct
     int count = 0;
-    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    for (Entry<Key,Value> entry : scanner) {
-      Key k = entry.getKey();
-      data[data.length - 1] = (byte) count;
-      String expected = new String(data, UTF_8);
-      Assert.assertEquals(expected, k.getRow().toString());
-      Assert.assertEquals("cf", k.getColumnFamily().toString());
-      Assert.assertEquals("cq", k.getColumnQualifier().toString());
-      Assert.assertEquals("value", entry.getValue().toString());
-      count++;
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> entry : scanner) {
+        Key k = entry.getKey();
+        data[data.length - 1] = (byte) count;
+        String expected = new String(data, UTF_8);
+        Assert.assertEquals(expected, k.getRow().toString());
+        Assert.assertEquals("cf", k.getColumnFamily().toString());
+        Assert.assertEquals("cq", k.getColumnQualifier().toString());
+        Assert.assertEquals("value", entry.getValue().toString());
+        count++;
+      }
     }
     Assert.assertEquals(250, count);
 
@@ -256,31 +258,31 @@ private void automaticSplit(int max, int spacing) throws Exception {
     // Make sure all the data that was put in the table is still correct
     int count = 0;
     int extra = 10;
-    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    for (Entry<Key,Value> entry : scanner) {
-      if (extra == 10) {
-        extra = 0;
-        for (int i = 0; i < data.length - 1; i++) {
-          data[i] = (byte) count;
-        }
-        count += spacing;
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> entry : scanner) {
+        if (extra == 10) {
+          extra = 0;
+          for (int i = 0; i < data.length - 1; i++) {
+            data[i] = (byte) count;
+          }
+          count += spacing;
 
+        }
+        Key k = entry.getKey();
+        data[data.length - 1] = (byte) extra;
+        String expected = new String(data, UTF_8);
+        Assert.assertEquals(expected, k.getRow().toString());
+        Assert.assertEquals("cf", k.getColumnFamily().toString());
+        Assert.assertEquals("cq", k.getColumnQualifier().toString());
+        Assert.assertEquals("value", entry.getValue().toString());
+        extra++;
       }
-      Key k = entry.getKey();
-      data[data.length - 1] = (byte) extra;
-      String expected = new String(data, UTF_8);
-      Assert.assertEquals(expected, k.getRow().toString());
-      Assert.assertEquals("cf", k.getColumnFamily().toString());
-      Assert.assertEquals("cq", k.getColumnQualifier().toString());
-      Assert.assertEquals("value", entry.getValue().toString());
-      extra++;
     }
     Assert.assertEquals(10, extra);
     Assert.assertEquals(max, count);
 
     // Make sure no splits occured in the table
     Assert.assertEquals(0, conn.tableOperations().listSplits(tableName).size());
-
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java b/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
index 1476900f6a..47b655d079 100644
--- a/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
@@ -68,6 +68,7 @@ public void run() {
             while (iterator.hasNext() && stop.get() == false) {
               iterator.next();
             }
+            s.close();
           }
         } catch (Exception ex) {
           log.trace("{}", ex.getMessage(), ex);
@@ -112,6 +113,7 @@ public void test() throws Exception {
     t2.interrupt();
     t1.join();
     t2.join();
+    m.close();
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
index 0c16a5fa74..338c1436a3 100644
--- a/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
@@ -86,10 +86,10 @@ public void test() throws Exception {
     getCluster().start();
     log.info("Verifying");
     for (String table : tables) {
-      BatchScanner scanner = c.createBatchScanner(table, Authorizations.EMPTY, 5);
-      scanner.setRanges(Collections.singletonList(new Range()));
-      assertEquals(1000, Iterators.size(scanner.iterator()));
-      scanner.close();
+      try (BatchScanner scanner = c.createBatchScanner(table, Authorizations.EMPTY, 5)) {
+        scanner.setRanges(Collections.singletonList(new Range()));
+        assertEquals(1000, Iterators.size(scanner.iterator()));
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
index 49d2b6d94d..8b13da187f 100644
--- a/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
@@ -150,8 +150,9 @@ public void testEmptyWalRecoveryCompletes() throws Exception {
 
     // Reading the table implies that recovery completed successfully (the empty file was ignored)
     // otherwise the tablet will never come online and we won't be able to read it.
-    Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
-    Assert.assertEquals(0, Iterables.size(s));
+    try (Scanner s = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      Assert.assertEquals(0, Iterables.size(s));
+    }
   }
 
   @Test
@@ -205,8 +206,9 @@ public void testPartialHeaderWalRecoveryCompletes() throws Exception {
 
     // Reading the table implies that recovery completed successfully (the empty file was ignored)
     // otherwise the tablet will never come online and we won't be able to read it.
-    Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
-    Assert.assertEquals(0, Iterables.size(s));
+    try (Scanner s = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      Assert.assertEquals(0, Iterables.size(s));
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java b/test/src/main/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
index d33b12cd7f..f36879d0f6 100644
--- a/test/src/main/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MultiTableBatchWriterIT.java
@@ -106,24 +106,35 @@ public void testTableRenameDataValidation() throws Exception {
       table2Expectations.put(Maps.immutableEntry("foo", "col1"), "val1");
       table2Expectations.put(Maps.immutableEntry("bar", "col1"), "val1");
 
-      Scanner s = connector.createScanner(table1, new Authorizations());
-      s.setRange(new Range());
+      Scanner s = null;
       Map<Entry<String,String>,String> actual = new HashMap<>();
-      for (Entry<Key,Value> entry : s) {
-        actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
-      }
-
-      Assert.assertEquals("Differing results for " + table1, table1Expectations, actual);
 
-      s = connector.createScanner(table2, new Authorizations());
-      s.setRange(new Range());
-      actual = new HashMap<>();
-      for (Entry<Key,Value> entry : s) {
-        actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+      try {
+        s = connector.createScanner(table1, new Authorizations());
+        s.setRange(new Range());
+        for (Entry<Key,Value> entry : s) {
+          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+        }
+        Assert.assertEquals("Differing results for " + table1, table1Expectations, actual);
+      } finally {
+        if (s != null) {
+          s.close();
+        }
       }
 
-      Assert.assertEquals("Differing results for " + table2, table2Expectations, actual);
-
+      try {
+        s = connector.createScanner(table2, new Authorizations());
+        s.setRange(new Range());
+        actual = new HashMap<>();
+        for (Entry<Key,Value> entry : s) {
+          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+        }
+        Assert.assertEquals("Differing results for " + table2, table2Expectations, actual);
+      } finally {
+        if (s != null) {
+          s.close();
+        }
+      }
     } finally {
       if (null != mtbw) {
         mtbw.close();
@@ -171,14 +182,14 @@ public void testTableRenameSameWriters() throws Exception {
       expectations.put(Maps.immutableEntry("bar", "col2"), "val2");
 
       for (String table : Arrays.asList(newTable1, newTable2)) {
-        Scanner s = connector.createScanner(table, new Authorizations());
-        s.setRange(new Range());
-        Map<Entry<String,String>,String> actual = new HashMap<>();
-        for (Entry<Key,Value> entry : s) {
-          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+        try (Scanner s = connector.createScanner(table, new Authorizations())) {
+          s.setRange(new Range());
+          Map<Entry<String,String>,String> actual = new HashMap<>();
+          for (Entry<Key,Value> entry : s) {
+            actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+          }
+          Assert.assertEquals("Differing results for " + table, expectations, actual);
         }
-
-        Assert.assertEquals("Differing results for " + table, expectations, actual);
       }
     } finally {
       if (null != mtbw) {
@@ -247,14 +258,14 @@ public void testTableRenameNewWriters() throws Exception {
       expectations.put(Maps.immutableEntry("bar", "col2"), "val2");
 
       for (String table : Arrays.asList(newTable1, newTable2)) {
-        Scanner s = connector.createScanner(table, new Authorizations());
-        s.setRange(new Range());
-        Map<Entry<String,String>,String> actual = new HashMap<>();
-        for (Entry<Key,Value> entry : s) {
-          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+        try (Scanner s = connector.createScanner(table, new Authorizations())) {
+          s.setRange(new Range());
+          Map<Entry<String,String>,String> actual = new HashMap<>();
+          for (Entry<Key,Value> entry : s) {
+            actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
+          }
+          Assert.assertEquals("Differing results for " + table, expectations, actual);
         }
-
-        Assert.assertEquals("Differing results for " + table, expectations, actual);
       }
     } finally {
       if (null != mtbw) {
diff --git a/test/src/main/java/org/apache/accumulo/test/MultiTableRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/MultiTableRecoveryIT.java
index 94db212f2c..890f6285c1 100644
--- a/test/src/main/java/org/apache/accumulo/test/MultiTableRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MultiTableRecoveryIT.java
@@ -99,13 +99,13 @@ public void testRecoveryOverMultipleTables() throws Exception {
     System.out.println("checking the data");
     long count = 0;
     for (int w = 0; w < N; w++) {
-      Scanner scanner = c.createScanner(tables[w], Authorizations.EMPTY);
-      for (Entry<Key,Value> entry : scanner) {
-        int value = Integer.parseInt(entry.getValue().toString());
-        assertEquals(w, value);
-        count++;
+      try (Scanner scanner = c.createScanner(tables[w], Authorizations.EMPTY)) {
+        for (Entry<Key,Value> entry : scanner) {
+          int value = Integer.parseInt(entry.getValue().toString());
+          assertEquals(w, value);
+          count++;
+        }
       }
-      scanner.close();
     }
     assertEquals(1_000_000, count);
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java b/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
index 31b701681b..9379e5fc1c 100644
--- a/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
@@ -325,35 +325,43 @@ public void verifyIteratorInheritance() throws Exception {
     IteratorSetting setting = new IteratorSetting(250, iterName, SimpleFilter.class.getName());
 
     // verify can see inserted entry
-    Scanner s = c.createScanner(t1, Authorizations.EMPTY);
-    assertTrue(s.iterator().hasNext());
-    assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
-    assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
-
-    // verify entry is filtered out (also, verify conflict checking API)
-    c.namespaceOperations().checkIteratorConflicts(namespace, setting, EnumSet.allOf(IteratorScope.class));
-    c.namespaceOperations().attachIterator(namespace, setting);
-    sleepUninterruptibly(2, TimeUnit.SECONDS);
+    Scanner s = null;
     try {
+      s = c.createScanner(t1, Authorizations.EMPTY);
+      assertTrue(s.iterator().hasNext());
+      assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
+      assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
+
+      // verify entry is filtered out (also, verify conflict checking API)
       c.namespaceOperations().checkIteratorConflicts(namespace, setting, EnumSet.allOf(IteratorScope.class));
-      fail();
-    } catch (AccumuloException e) {
-      assertEquals(IllegalArgumentException.class.getName(), e.getCause().getClass().getName());
+      c.namespaceOperations().attachIterator(namespace, setting);
+      sleepUninterruptibly(2, TimeUnit.SECONDS);
+      try {
+        c.namespaceOperations().checkIteratorConflicts(namespace, setting, EnumSet.allOf(IteratorScope.class));
+        fail();
+      } catch (AccumuloException e) {
+        assertEquals(IllegalArgumentException.class.getName(), e.getCause().getClass().getName());
+      }
+      IteratorSetting setting2 = c.namespaceOperations().getIteratorSetting(namespace, setting.getName(), IteratorScope.scan);
+      assertEquals(setting, setting2);
+      assertTrue(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
+      assertTrue(c.tableOperations().listIterators(t1).containsKey(iterName));
+      s = c.createScanner(t1, Authorizations.EMPTY);
+      assertFalse(s.iterator().hasNext());
+
+      // verify can see inserted entry again
+      c.namespaceOperations().removeIterator(namespace, setting.getName(), EnumSet.allOf(IteratorScope.class));
+      sleepUninterruptibly(2, TimeUnit.SECONDS);
+      assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
+      assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
+      s = c.createScanner(t1, Authorizations.EMPTY);
+      assertTrue(s.iterator().hasNext());
+      s.close();
+    } finally {
+      if (s != null) {
+        s.close();
+      }
     }
-    IteratorSetting setting2 = c.namespaceOperations().getIteratorSetting(namespace, setting.getName(), IteratorScope.scan);
-    assertEquals(setting, setting2);
-    assertTrue(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
-    assertTrue(c.tableOperations().listIterators(t1).containsKey(iterName));
-    s = c.createScanner(t1, Authorizations.EMPTY);
-    assertFalse(s.iterator().hasNext());
-
-    // verify can see inserted entry again
-    c.namespaceOperations().removeIterator(namespace, setting.getName(), EnumSet.allOf(IteratorScope.class));
-    sleepUninterruptibly(2, TimeUnit.SECONDS);
-    assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
-    assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
-    s = c.createScanner(t1, Authorizations.EMPTY);
-    assertTrue(s.iterator().hasNext());
   }
 
   @Test
diff --git a/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java b/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java
index b268fb46ae..418045b967 100644
--- a/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java
+++ b/test/src/main/java/org/apache/accumulo/test/QueryMetadataTable.java
@@ -63,11 +63,12 @@
 
     @Override
     public void run() {
+      Scanner mdScanner = null;
       try {
         KeyExtent extent = new KeyExtent(row, (Text) null);
 
         Connector connector = HdfsZooInstance.getInstance().getConnector(principal, token);
-        Scanner mdScanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+        mdScanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
         Text row = extent.getMetadataEntry();
 
         mdScanner.setRange(new Range(row));
@@ -77,6 +78,7 @@ public void run() {
             break;
         }
 
+        mdScanner.close();
       } catch (TableNotFoundException e) {
         log.error("Table '" + MetadataTable.NAME + "' not found.", e);
         throw new RuntimeException(e);
@@ -86,6 +88,10 @@ public void run() {
       } catch (AccumuloSecurityException e) {
         log.error("AccumuloSecurityException encountered.", e);
         throw new RuntimeException(e);
+      } finally {
+        if (mdScanner != null) {
+          mdScanner.close();
+        }
       }
     }
   }
@@ -103,27 +109,28 @@ public static void main(String[] args) throws AccumuloException, AccumuloSecurit
     opts.parseArgs(QueryMetadataTable.class.getName(), args, scanOpts);
 
     Connector connector = opts.getConnector();
-    Scanner scanner = connector.createScanner(MetadataTable.NAME, opts.auths);
-    scanner.setBatchSize(scanOpts.scanBatchSize);
-    Text mdrow = new Text(KeyExtent.getMetadataEntry(MetadataTable.ID, null));
-
     HashSet<Text> rowSet = new HashSet<>();
 
     int count = 0;
 
-    for (Entry<Key,Value> entry : scanner) {
-      System.out.print(".");
-      if (count % 72 == 0) {
-        System.out.printf(" %,d%n", count);
-      }
-      if (entry.getKey().compareRow(mdrow) == 0 && entry.getKey().getColumnFamily().compareTo(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
-        System.out.println(entry.getKey() + " " + entry.getValue());
-        location = entry.getValue().toString();
-      }
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, opts.auths)) {
+      scanner.setBatchSize(scanOpts.scanBatchSize);
+      Text mdrow = new Text(KeyExtent.getMetadataEntry(MetadataTable.ID, null));
 
-      if (!entry.getKey().getRow().toString().startsWith(MetadataTable.ID.canonicalID()))
-        rowSet.add(entry.getKey().getRow());
-      count++;
+      for (Entry<Key,Value> entry : scanner) {
+        System.out.print(".");
+        if (count % 72 == 0) {
+          System.out.printf(" %,d%n", count);
+        }
+        if (entry.getKey().compareRow(mdrow) == 0 && entry.getKey().getColumnFamily().compareTo(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
+          System.out.println(entry.getKey() + " " + entry.getValue());
+          location = entry.getValue().toString();
+        }
+
+        if (!entry.getKey().getRow().toString().startsWith(MetadataTable.ID.canonicalID()))
+          rowSet.add(entry.getKey().getRow());
+        count++;
+      }
     }
 
     System.out.printf(" %,d%n", count);
diff --git a/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java b/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
index f79e1748d9..1b7bb90fe7 100644
--- a/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
@@ -89,12 +89,13 @@ public void test() throws Exception {
     Iterators.size(c.createScanner(tableName, Authorizations.EMPTY).iterator());
 
     // ensure that the recovery was not a merging minor compaction
-    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    for (Entry<Key,Value> entry : s) {
-      String filename = entry.getKey().getColumnQualifier().toString();
-      String parts[] = filename.split("/");
-      Assert.assertFalse(parts[parts.length - 1].startsWith("M"));
+    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      for (Entry<Key,Value> entry : s) {
+        String filename = entry.getKey().getColumnQualifier().toString();
+        String parts[] = filename.split("/");
+        Assert.assertFalse(parts[parts.length - 1].startsWith("M"));
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java b/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
index 2189fff0e8..96e000e794 100644
--- a/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
@@ -98,72 +98,73 @@ public void test() throws Exception {
     bw.close();
     c.tableOperations().addSplits(tableName, splits);
 
-    BatchScanner scanner = c.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1);
-    DIRECTORY_COLUMN.fetch(scanner);
-    Table.ID tableId = Table.ID.of(c.tableOperations().tableIdMap().get(tableName));
-    assertNotNull("TableID for " + tableName + " was null", tableId);
-    scanner.setRanges(Collections.singletonList(TabletsSection.getRange(tableId)));
-    // verify the directory entries are all on v1, make a few entries relative
-    bw = c.createBatchWriter(MetadataTable.NAME, null);
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      assertTrue("Expected " + entry.getValue() + " to contain " + v1, entry.getValue().toString().contains(v1.toString()));
-      count++;
-      if (count % 2 == 0) {
-        String parts[] = entry.getValue().toString().split("/");
-        Key key = entry.getKey();
-        Mutation m = new Mutation(key.getRow());
-        m.put(key.getColumnFamily(), key.getColumnQualifier(), new Value((Path.SEPARATOR + parts[parts.length - 1]).getBytes()));
-        bw.addMutation(m);
+    try (BatchScanner scanner = c.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1)) {
+      DIRECTORY_COLUMN.fetch(scanner);
+      Table.ID tableId = Table.ID.of(c.tableOperations().tableIdMap().get(tableName));
+      assertNotNull("TableID for " + tableName + " was null", tableId);
+      scanner.setRanges(Collections.singletonList(TabletsSection.getRange(tableId)));
+      // verify the directory entries are all on v1, make a few entries relative
+      bw = c.createBatchWriter(MetadataTable.NAME, null);
+      int count = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        assertTrue("Expected " + entry.getValue() + " to contain " + v1, entry.getValue().toString().contains(v1.toString()));
+        count++;
+        if (count % 2 == 0) {
+          String parts[] = entry.getValue().toString().split("/");
+          Key key = entry.getKey();
+          Mutation m = new Mutation(key.getRow());
+          m.put(key.getColumnFamily(), key.getColumnQualifier(), new Value((Path.SEPARATOR + parts[parts.length - 1]).getBytes()));
+          bw.addMutation(m);
+        }
       }
-    }
-    bw.close();
-    assertEquals(splits.size() + 1, count);
-
-    // This should fail: only one volume
-    assertEquals(1, cluster.exec(RandomizeVolumes.class, "-z", cluster.getZooKeepers(), "-i", c.getInstance().getInstanceName(), "-t", tableName).waitFor());
-
-    cluster.stop();
-
-    // add the 2nd volume
-    Configuration conf = new Configuration(false);
-    conf.addResource(new Path(cluster.getConfig().getConfDir().toURI().toString(), "accumulo-site.xml"));
-    conf.set(Property.INSTANCE_VOLUMES.getKey(), v1.toString() + "," + v2.toString());
-    BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(cluster.getConfig().getConfDir(), "accumulo-site.xml")));
-    conf.writeXml(fos);
-    fos.close();
-
-    // initialize volume
-    assertEquals(0, cluster.exec(Initialize.class, "--add-volumes").waitFor());
-    cluster.start();
-    c = getConnector();
-
-    // change the directory entries
-    assertEquals(0, cluster.exec(Admin.class, "randomizeVolumes", "-t", tableName).waitFor());
-
-    // verify a more equal sharing
-    int v1Count = 0, v2Count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry.getValue().toString().contains(v1.toString())) {
-        v1Count++;
-      }
-      if (entry.getValue().toString().contains(v2.toString())) {
-        v2Count++;
+      bw.close();
+      assertEquals(splits.size() + 1, count);
+
+      // This should fail: only one volume
+      assertEquals(1, cluster.exec(RandomizeVolumes.class, "-z", cluster.getZooKeepers(), "-i", c.getInstance().getInstanceName(), "-t", tableName).waitFor());
+
+      cluster.stop();
+
+      // add the 2nd volume
+      Configuration conf = new Configuration(false);
+      conf.addResource(new Path(cluster.getConfig().getConfDir().toURI().toString(), "accumulo-site.xml"));
+      conf.set(Property.INSTANCE_VOLUMES.getKey(), v1.toString() + "," + v2.toString());
+      BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(new File(cluster.getConfig().getConfDir(), "accumulo-site.xml")));
+      conf.writeXml(fos);
+      fos.close();
+
+      // initialize volume
+      assertEquals(0, cluster.exec(Initialize.class, "--add-volumes").waitFor());
+      cluster.start();
+      c = getConnector();
+
+      // change the directory entries
+      assertEquals(0, cluster.exec(Admin.class, "randomizeVolumes", "-t", tableName).waitFor());
+
+      // verify a more equal sharing
+      int v1Count = 0, v2Count = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry.getValue().toString().contains(v1.toString())) {
+          v1Count++;
+        }
+        if (entry.getValue().toString().contains(v2.toString())) {
+          v2Count++;
+        }
       }
-    }
 
-    log.info("Count for volume1: {}", v1Count);
-    log.info("Count for volume2: {}", v2Count);
-
-    assertEquals(splits.size() + 1, v1Count + v2Count);
-    // a fair chooser will differ by less than count(volumes)
-    assertTrue("Expected the number of files to differ between volumes by less than 10. " + v1Count + " " + v2Count, Math.abs(v1Count - v2Count) < 2);
-    // verify we can read the old data
-    count = 0;
-    for (Entry<Key,Value> entry : c.createScanner(tableName, Authorizations.EMPTY)) {
-      assertTrue("Found unexpected entry in table: " + entry, splits.contains(entry.getKey().getRow()));
-      count++;
+      log.info("Count for volume1: {}", v1Count);
+      log.info("Count for volume2: {}", v2Count);
+
+      assertEquals(splits.size() + 1, v1Count + v2Count);
+      // a fair chooser will differ by less than count(volumes)
+      assertTrue("Expected the number of files to differ between volumes by less than 10. " + v1Count + " " + v2Count, Math.abs(v1Count - v2Count) < 2);
+      // verify we can read the old data
+      count = 0;
+      for (Entry<Key,Value> entry : c.createScanner(tableName, Authorizations.EMPTY)) {
+        assertTrue("Found unexpected entry in table: " + entry, splits.contains(entry.getKey().getRow()));
+        count++;
+      }
+      assertEquals(splits.size(), count);
     }
-    assertEquals(splits.size(), count);
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/SampleIT.java b/test/src/main/java/org/apache/accumulo/test/SampleIT.java
index a195d4bb85..41c5bb9de2 100644
--- a/test/src/main/java/org/apache/accumulo/test/SampleIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SampleIT.java
@@ -128,6 +128,7 @@ public void testBasic() throws Exception {
     String someRow = writeData(bw, SC1, expected);
     Assert.assertEquals(20, expected.size());
 
+
     Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
     Scanner isoScanner = new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY));
     Scanner csiScanner = new ClientSideIteratorScanner(conn.createScanner(tableName, Authorizations.EMPTY));
@@ -193,8 +194,6 @@ public void testBasic() throws Exception {
     expected.put(new Key(someRow, "cf1", "cq3", 8), new Value("suprise".getBytes()));
 
     check(expected, scanner, bScanner, isoScanner, csiScanner, oScanner);
-
-    bScanner.close();
   }
 
   private Scanner newOfflineScanner(Connector conn, String tableName, String clone, SamplerConfiguration sc) throws Exception {
@@ -311,64 +310,87 @@ public void testIterator() throws Exception {
 
     Range range1 = new Range(keys.get(6), true, keys.get(11), true);
 
-    Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    Scanner isoScanner = new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY));
-    ClientSideIteratorScanner csiScanner = new ClientSideIteratorScanner(conn.createScanner(tableName, Authorizations.EMPTY));
-    BatchScanner bScanner = conn.createBatchScanner(tableName, Authorizations.EMPTY, 2);
+    Scanner scanner = null;
+    Scanner isoScanner = null;
+    ClientSideIteratorScanner csiScanner = null;
+    BatchScanner bScanner = null;
+    Scanner oScanner = null;
+    try {
+      scanner = conn.createScanner(tableName, Authorizations.EMPTY);
+      isoScanner = new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY));
+      csiScanner = new ClientSideIteratorScanner(conn.createScanner(tableName, Authorizations.EMPTY));
+      bScanner = conn.createBatchScanner(tableName, Authorizations.EMPTY, 2);
 
-    csiScanner.setIteratorSamplerConfiguration(SC1);
+      csiScanner.setIteratorSamplerConfiguration(SC1);
 
-    List<? extends ScannerBase> scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner);
+      List<? extends ScannerBase> scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner);
 
-    for (ScannerBase s : scanners) {
-      s.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
-    }
+      for (ScannerBase s : scanners) {
+        s.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
+      }
 
-    // the iterator should see less than 10 entries in sample data, and return data
-    setRange(range1, scanners);
-    for (ScannerBase s : scanners) {
-      Assert.assertEquals(2954, countEntries(s));
-    }
+      // the iterator should see less than 10 entries in sample data, and return data
+      setRange(range1, scanners);
+      for (ScannerBase s : scanners) {
+        Assert.assertEquals(2954, countEntries(s));
+      }
 
-    Range range2 = new Range(keys.get(5), true, keys.get(18), true);
-    setRange(range2, scanners);
+      Range range2 = new Range(keys.get(5), true, keys.get(18), true);
+      setRange(range2, scanners);
 
-    // the iterator should see more than 10 entries in sample data, and return no data
-    for (ScannerBase s : scanners) {
-      Assert.assertEquals(0, countEntries(s));
-    }
+      // the iterator should see more than 10 entries in sample data, and return no data
+      for (ScannerBase s : scanners) {
+        Assert.assertEquals(0, countEntries(s));
+      }
 
-    // flush an rerun same test against files
-    conn.tableOperations().flush(tableName, null, null, true);
+      // flush an rerun same test against files
+      conn.tableOperations().flush(tableName, null, null, true);
 
-    Scanner oScanner = newOfflineScanner(conn, tableName, clone, null);
-    oScanner.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
-    scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner, oScanner);
+      oScanner = newOfflineScanner(conn, tableName, clone, null);
+      oScanner.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
+      scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner, oScanner);
 
-    setRange(range1, scanners);
-    for (ScannerBase s : scanners) {
-      Assert.assertEquals(2954, countEntries(s));
-    }
+      setRange(range1, scanners);
+      for (ScannerBase s : scanners) {
+        Assert.assertEquals(2954, countEntries(s));
+      }
 
-    setRange(range2, scanners);
-    for (ScannerBase s : scanners) {
-      Assert.assertEquals(0, countEntries(s));
-    }
+      setRange(range2, scanners);
+      for (ScannerBase s : scanners) {
+        Assert.assertEquals(0, countEntries(s));
+      }
 
-    updateSamplingConfig(conn, tableName, SC2);
+      updateSamplingConfig(conn, tableName, SC2);
 
-    csiScanner.setIteratorSamplerConfiguration(SC2);
+      csiScanner.setIteratorSamplerConfiguration(SC2);
 
-    oScanner = newOfflineScanner(conn, tableName, clone, null);
-    oScanner.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
-    scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner, oScanner);
+      oScanner = newOfflineScanner(conn, tableName, clone, null);
+      oScanner.addScanIterator(new IteratorSetting(100, IteratorThatUsesSample.class));
+      scanners = Arrays.asList(scanner, isoScanner, bScanner, csiScanner, oScanner);
 
-    for (ScannerBase s : scanners) {
-      try {
-        countEntries(s);
-        Assert.fail("Expected SampleNotPresentException, but it did not happen : " + s.getClass().getSimpleName());
-      } catch (SampleNotPresentException e) {
+      for (ScannerBase s : scanners) {
+        try {
+          countEntries(s);
+          Assert.fail("Expected SampleNotPresentException, but it did not happen : " + s.getClass().getSimpleName());
+        } catch (SampleNotPresentException e) {
 
+        }
+      }
+    }  finally {
+      if (scanner != null) {
+        scanner.close();
+      }
+      if (bScanner != null) {
+        bScanner.close();
+      }
+      if (isoScanner != null) {
+        isoScanner.close();
+      }
+      if (csiScanner != null) {
+        csiScanner.close();
+      }
+      if (oScanner != null) {
+        oScanner.close();
       }
     }
   }
@@ -442,8 +464,6 @@ public void testSampleNotPresent() throws Exception {
     oScanner = newOfflineScanner(conn, tableName, clone, SC2);
     setSamplerConfig(SC2, scanner, csiScanner, isoScanner, bScanner, oScanner);
     check(expected, scanner, isoScanner, bScanner, csiScanner, oScanner);
-
-    bScanner.close();
   }
 
   private void updateSamplingConfig(Connector conn, String tableName, SamplerConfiguration sc) throws TableNotFoundException, AccumuloException,
diff --git a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
index 6dd9b4236b..2a74388fd9 100644
--- a/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ShellServerIT.java
@@ -1508,62 +1508,61 @@ public void listscans() throws Exception {
       ts.exec("insert " + i + " cf cq value", true);
     }
     Connector connector = getConnector();
-    final Scanner s = connector.createScanner(table, Authorizations.EMPTY);
-    IteratorSetting cfg = new IteratorSetting(30, SlowIterator.class);
-    SlowIterator.setSleepTime(cfg, 500);
-    s.addScanIterator(cfg);
-
-    Thread thread = new Thread() {
-      @Override
-      public void run() {
-        try {
-          Iterators.size(s.iterator());
-        } catch (Exception ex) {
-          throw new RuntimeException(ex);
+    try (Scanner s = connector.createScanner(table, Authorizations.EMPTY)) {
+      IteratorSetting cfg = new IteratorSetting(30, SlowIterator.class);
+      SlowIterator.setSleepTime(cfg, 500);
+      s.addScanIterator(cfg);
+
+      Thread thread = new Thread() {
+        @Override public void run() {
+          try {
+            Iterators.size(s.iterator());
+          } catch (Exception ex) {
+            throw new RuntimeException(ex);
+          }
         }
-      }
-    };
-    thread.start();
-
-    List<String> scans = new ArrayList<>();
-    // Try to find the active scan for about 15seconds
-    for (int i = 0; i < 50 && scans.isEmpty(); i++) {
-      String currentScans = ts.exec("listscans", true);
-      log.info("Got output from listscans:\n{}", currentScans);
-      String[] lines = currentScans.split("\n");
-      for (int scanOffset = 2; scanOffset < lines.length; scanOffset++) {
-        String currentScan = lines[scanOffset];
-        if (currentScan.contains(table)) {
-          log.info("Retaining scan: {}", currentScan);
-          scans.add(currentScan);
-        } else {
-          log.info("Ignoring scan because of wrong table: {}", currentScan);
+      };
+      thread.start();
+
+      List<String> scans = new ArrayList<>();
+      // Try to find the active scan for about 15seconds
+      for (int i = 0; i < 50 && scans.isEmpty(); i++) {
+        String currentScans = ts.exec("listscans", true);
+        log.info("Got output from listscans:\n{}", currentScans);
+        String[] lines = currentScans.split("\n");
+        for (int scanOffset = 2; scanOffset < lines.length; scanOffset++) {
+          String currentScan = lines[scanOffset];
+          if (currentScan.contains(table)) {
+            log.info("Retaining scan: {}", currentScan);
+            scans.add(currentScan);
+          } else {
+            log.info("Ignoring scan because of wrong table: {}", currentScan);
+          }
         }
+        sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
       }
-      sleepUninterruptibly(300, TimeUnit.MILLISECONDS);
-    }
-    thread.join();
+      thread.join();
 
-    assertFalse("Could not find any active scans over table " + table, scans.isEmpty());
+      assertFalse("Could not find any active scans over table " + table, scans.isEmpty());
 
-    for (String scan : scans) {
-      if (!scan.contains("RUNNING")) {
-        log.info("Ignoring scan because it doesn't contain 'RUNNING': {}", scan);
-        continue;
+      for (String scan : scans) {
+        if (!scan.contains("RUNNING")) {
+          log.info("Ignoring scan because it doesn't contain 'RUNNING': {}", scan);
+          continue;
+        }
+        String parts[] = scan.split("\\|");
+        assertEquals("Expected 14 colums, but found " + parts.length + " instead for '" + Arrays.toString(parts) + "'", 14, parts.length);
+        String tserver = parts[0].trim();
+        // TODO: any way to tell if the client address is accurate? could be local IP, host, loopback...?
+        String hostPortPattern = ".+:\\d+";
+        assertTrue(tserver.matches(hostPortPattern));
+        assertTrue(getConnector().instanceOperations().getTabletServers().contains(tserver));
+        String client = parts[1].trim();
+        assertTrue(client + " does not match " + hostPortPattern, client.matches(hostPortPattern));
+        // Scan ID should be a long (throwing an exception if it fails to parse)
+        Long.parseLong(parts[11].trim());
       }
-      String parts[] = scan.split("\\|");
-      assertEquals("Expected 14 colums, but found " + parts.length + " instead for '" + Arrays.toString(parts) + "'", 14, parts.length);
-      String tserver = parts[0].trim();
-      // TODO: any way to tell if the client address is accurate? could be local IP, host, loopback...?
-      String hostPortPattern = ".+:\\d+";
-      assertTrue(tserver.matches(hostPortPattern));
-      assertTrue(getConnector().instanceOperations().getTabletServers().contains(tserver));
-      String client = parts[1].trim();
-      assertTrue(client + " does not match " + hostPortPattern, client.matches(hostPortPattern));
-      // Scan ID should be a long (throwing an exception if it fails to parse)
-      Long.parseLong(parts[11].trim());
     }
-
     ts.exec("deletetable -f " + table, true);
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
index 724c5e8f07..620e8b3a06 100644
--- a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
@@ -54,10 +54,11 @@ private Mutation m(String row) {
 
   boolean isOffline(String tablename, Connector connector) throws TableNotFoundException {
     String tableId = connector.tableOperations().tableIdMap().get(tablename);
-    Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new Range(new Text(tableId + ";"), new Text(tableId + "<")));
-    scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
-    return Iterators.size(scanner.iterator()) == 0;
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(new Range(new Text(tableId + ";"), new Text(tableId + "<")));
+      scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
+      return Iterators.size(scanner.iterator()) == 0;
+    }
   }
 
   @Override
@@ -101,20 +102,21 @@ public void test() throws Exception {
 
         bw.flush();
 
-        Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-        scanner.setRange(extent.toMetadataRange());
-        scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
+        try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+          scanner.setRange(extent.toMetadataRange());
+          scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
 
-        KeyExtent extent2 = new KeyExtent(tableId, new Text("b"), null);
-        m = extent2.getPrevRowUpdateMutation();
-        TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value("/t2".getBytes()));
-        TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value("M0".getBytes()));
+          KeyExtent extent2 = new KeyExtent(tableId, new Text("b"), null);
+          m = extent2.getPrevRowUpdateMutation();
+          TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value("/t2".getBytes()));
+          TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value("M0".getBytes()));
 
-        for (Entry<Key,Value> entry : scanner) {
-          m.put(DataFileColumnFamily.NAME, entry.getKey().getColumnQualifier(), entry.getValue());
-        }
+          for (Entry<Key,Value> entry : scanner) {
+            m.put(DataFileColumnFamily.NAME, entry.getKey().getColumnQualifier(), entry.getValue());
+          }
 
-        bw.addMutation(m);
+          bw.addMutation(m);
+        }
       }
 
       bw.close();
@@ -122,17 +124,17 @@ public void test() throws Exception {
       connector.tableOperations().online(tableName);
 
       // verify the tablets went online
-      Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-      int i = 0;
-      String expected[] = {"a", "b", "c"};
-      for (Entry<Key,Value> entry : scanner) {
-        assertEquals(expected[i], entry.getKey().getRow().toString());
-        i++;
-      }
-      assertEquals(3, i);
-
-      connector.tableOperations().delete(tableName);
+      try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+        int i = 0;
+        String expected[] = {"a", "b", "c"};
+        for (Entry<Key,Value> entry : scanner) {
+          assertEquals(expected[i], entry.getKey().getRow().toString());
+          i++;
+        }
+        assertEquals(3, i);
 
+        connector.tableOperations().delete(tableName);
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
index 807e425805..0fb2813474 100644
--- a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
@@ -211,20 +211,21 @@ public void createMergeClonedTable() throws Exception {
     tops.merge(clonedTable, null, new Text("b"));
 
     Map<String,Integer> rowCounts = new HashMap<>();
-    Scanner s = connector.createScanner(clonedTable, new Authorizations());
-    for (Entry<Key,Value> entry : s) {
-      final Key key = entry.getKey();
-      String row = key.getRow().toString();
-      String cf = key.getColumnFamily().toString(), cq = key.getColumnQualifier().toString();
-      String value = entry.getValue().toString();
-
-      if (rowCounts.containsKey(row)) {
-        rowCounts.put(row, rowCounts.get(row) + 1);
-      } else {
-        rowCounts.put(row, 1);
-      }
+    try (Scanner s = connector.createScanner(clonedTable, new Authorizations())) {
+      for (Entry<Key,Value> entry : s) {
+        final Key key = entry.getKey();
+        String row = key.getRow().toString();
+        String cf = key.getColumnFamily().toString(), cq = key.getColumnQualifier().toString();
+        String value = entry.getValue().toString();
+
+        if (rowCounts.containsKey(row)) {
+          rowCounts.put(row, rowCounts.get(row) + 1);
+        } else {
+          rowCounts.put(row, 1);
+        }
 
-      Assert.assertEquals(Integer.parseInt(cf) + Integer.parseInt(cq), Integer.parseInt(value));
+        Assert.assertEquals(Integer.parseInt(cf) + Integer.parseInt(cq), Integer.parseInt(value));
+      }
     }
 
     Collection<Text> clonedSplits = tops.listSplits(clonedTable);
@@ -232,7 +233,6 @@ public void createMergeClonedTable() throws Exception {
     for (Text clonedSplit : clonedSplits) {
       Assert.assertTrue("Encountered unexpected split on the cloned table: " + clonedSplit, expectedSplits.remove(clonedSplit));
     }
-
     Assert.assertTrue("Did not find all expected splits on the cloned table: " + expectedSplits, expectedSplits.isEmpty());
   }
 
@@ -253,12 +253,13 @@ public void testCompactEmptyTableWithGeneratorIterator() throws TableExistsExcep
     list.add(new IteratorSetting(15, HardListIterator.class));
     connector.tableOperations().compact(tableName, null, null, list, true, true);
 
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
-    for (Map.Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey(), entry.getValue());
-    assertEquals(HardListIterator.allEntriesToInject, actual);
-    connector.tableOperations().delete(tableName);
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
+      for (Map.Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey(), entry.getValue());
+      assertEquals(HardListIterator.allEntriesToInject, actual);
+      connector.tableOperations().delete(tableName);
+    }
   }
 
   /** Compare only the row, column family and column qualifier. */
@@ -284,12 +285,13 @@ public void testCompactEmptyTableWithGeneratorIterator_Splits() throws TableExis
     list.add(new IteratorSetting(15, HardListIterator.class));
     connector.tableOperations().compact(tableName, null, null, list, true, true);
 
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
-    for (Map.Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey(), entry.getValue());
-    assertEquals(HardListIterator.allEntriesToInject, actual);
-    connector.tableOperations().delete(tableName);
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
+      for (Map.Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey(), entry.getValue());
+      assertEquals(HardListIterator.allEntriesToInject, actual);
+      connector.tableOperations().delete(tableName);
+    }
   }
 
   @Test
@@ -307,31 +309,32 @@ public void testCompactEmptyTableWithGeneratorIterator_Splits_Cancel() throws Ta
     connector.tableOperations().cancelCompaction(tableName);
     // depending on timing, compaction will finish or be canceled
 
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
-    for (Map.Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey(), entry.getValue());
-    switch (actual.size()) {
-      case 3:
-        // Compaction cancel didn't happen in time
-        assertTrue(HardListIterator.allEntriesToInject.equals(actual));
-        break;
-      case 2:
-        // Compacted the first tablet (-inf, f)
-        assertEquals(HardListIterator.allEntriesToInject.headMap(new Key("f")), actual);
-        break;
-      case 1:
-        // Compacted the second tablet [f, +inf)
-        assertEquals(HardListIterator.allEntriesToInject.tailMap(new Key("f")), actual);
-        break;
-      case 0:
-        // Cancelled the compaction before it ran. No generated entries.
-        break;
-      default:
-        Assert.fail("Unexpected number of entries");
-        break;
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
+      for (Map.Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey(), entry.getValue());
+      switch (actual.size()) {
+        case 3:
+          // Compaction cancel didn't happen in time
+          assertTrue(HardListIterator.allEntriesToInject.equals(actual));
+          break;
+        case 2:
+          // Compacted the first tablet (-inf, f)
+          assertEquals(HardListIterator.allEntriesToInject.headMap(new Key("f")), actual);
+          break;
+        case 1:
+          // Compacted the second tablet [f, +inf)
+          assertEquals(HardListIterator.allEntriesToInject.tailMap(new Key("f")), actual);
+          break;
+        case 0:
+          // Cancelled the compaction before it ran. No generated entries.
+          break;
+        default:
+          Assert.fail("Unexpected number of entries");
+          break;
+      }
+      connector.tableOperations().delete(tableName);
     }
-    connector.tableOperations().delete(tableName);
   }
 
   @Test
@@ -349,13 +352,14 @@ public void testCompactEmptyTableWithGeneratorIterator_Splits_Partial() throws T
     // compact the second tablet, not the first
     connector.tableOperations().compact(tableName, splitRow, null, list, true, true);
 
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
-    for (Map.Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey(), entry.getValue());
-    // only expect the entries in the second tablet
-    assertEquals(HardListIterator.allEntriesToInject.tailMap(new Key(splitRow)), actual);
-    connector.tableOperations().delete(tableName);
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      Map<Key,Value> actual = new TreeMap<>(COMPARE_KEY_TO_COLQ); // only compare row, colF, colQ
+      for (Map.Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey(), entry.getValue());
+      // only expect the entries in the second tablet
+      assertEquals(HardListIterator.allEntriesToInject.tailMap(new Key(splitRow)), actual);
+      connector.tableOperations().delete(tableName);
+    }
   }
 
   /** Test recovery from bad majc iterator via compaction cancel. */
@@ -371,12 +375,13 @@ public void testCompactEmptyTablesWithBadIterator_FailsAndCancel() throws TableE
     sleepUninterruptibly(2, TimeUnit.SECONDS); // start compaction
     connector.tableOperations().cancelCompaction(tableName);
 
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    Map<Key,Value> actual = new TreeMap<>();
-    for (Map.Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey(), entry.getValue());
-    assertTrue("Should be empty. Actual is " + actual, actual.isEmpty());
-    connector.tableOperations().delete(tableName);
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      Map<Key,Value> actual = new TreeMap<>();
+      for (Map.Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey(), entry.getValue());
+      assertTrue("Should be empty. Actual is " + actual, actual.isEmpty());
+      connector.tableOperations().delete(tableName);
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
index a7f151dea7..e53b78c2fa 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestBinaryRows.java
@@ -104,46 +104,46 @@ public static void runTest(Connector connector, Opts opts, BatchWriterOpts bwOpt
 
       bw.close();
     } else if (opts.mode.equals("verifyDeleted")) {
-      Scanner s = connector.createScanner(opts.getTableName(), opts.auths);
-      s.setBatchSize(scanOpts.scanBatchSize);
-      Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
-      Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES, new byte[0], 0);
-      s.setBatchSize(50000);
-      s.setRange(new Range(startKey, stopKey));
-
-      for (Entry<Key,Value> entry : s) {
-        throw new Exception("ERROR : saw entries in range that should be deleted ( first value : " + entry.getValue().toString() + ")");
-      }
+      try (Scanner s = connector.createScanner(opts.getTableName(), opts.auths)) {
+        s.setBatchSize(scanOpts.scanBatchSize);
+        Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
+        Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES, new byte[0], 0);
+        s.setBatchSize(50000);
+        s.setRange(new Range(startKey, stopKey));
 
+        for (Entry<Key,Value> entry : s) {
+          throw new Exception("ERROR : saw entries in range that should be deleted ( first value : " + entry.getValue().toString() + ")");
+        }
+      }
     } else if (opts.mode.equals("verify")) {
       long t1 = System.currentTimeMillis();
 
-      Scanner s = connector.createScanner(opts.getTableName(), opts.auths);
-      Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
-      Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES, new byte[0], 0);
-      s.setBatchSize(scanOpts.scanBatchSize);
-      s.setRange(new Range(startKey, stopKey));
-
-      long i = opts.start;
+      try (Scanner s = connector.createScanner(opts.getTableName(), opts.auths)) {
+        Key startKey = new Key(encodeLong(opts.start), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
+        Key stopKey = new Key(encodeLong(opts.start + opts.num - 1), CF_BYTES, CQ_BYTES, new byte[0], 0);
+        s.setBatchSize(scanOpts.scanBatchSize);
+        s.setRange(new Range(startKey, stopKey));
 
-      for (Entry<Key,Value> e : s) {
-        Key k = e.getKey();
-        Value v = e.getValue();
+        long i = opts.start;
 
-        checkKeyValue(i, k, v);
+        for (Entry<Key,Value> e : s) {
+          Key k = e.getKey();
+          Value v = e.getValue();
 
-        i++;
-      }
+          checkKeyValue(i, k, v);
 
-      if (i != opts.start + opts.num) {
-        throw new Exception("ERROR : did not see expected number of rows, saw " + (i - opts.start) + " expected " + opts.num);
-      }
+          i++;
+        }
 
-      long t2 = System.currentTimeMillis();
+        if (i != opts.start + opts.num) {
+          throw new Exception("ERROR : did not see expected number of rows, saw " + (i - opts.start) + " expected " + opts.num);
+        }
 
-      System.out.printf("time : %9.2f secs%n", ((t2 - t1) / 1000.0));
-      System.out.printf("rate : %9.2f entries/sec%n", opts.num / ((t2 - t1) / 1000.0));
+        long t2 = System.currentTimeMillis();
 
+        System.out.printf("time : %9.2f secs%n", ((t2 - t1) / 1000.0));
+        System.out.printf("rate : %9.2f entries/sec%n", opts.num / ((t2 - t1) / 1000.0));
+      }
     } else if (opts.mode.equals("randomLookups")) {
       int numLookups = 1000;
 
@@ -154,27 +154,28 @@ public static void runTest(Connector connector, Opts opts, BatchWriterOpts bwOpt
       for (int i = 0; i < numLookups; i++) {
         long row = ((r.nextLong() & 0x7fffffffffffffffl) % opts.num) + opts.start;
 
-        Scanner s = connector.createScanner(opts.getTableName(), opts.auths);
-        s.setBatchSize(scanOpts.scanBatchSize);
-        Key startKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
-        Key stopKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], 0);
-        s.setRange(new Range(startKey, stopKey));
+        try (Scanner s = connector.createScanner(opts.getTableName(), opts.auths)) {
+          s.setBatchSize(scanOpts.scanBatchSize);
+          Key startKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], Long.MAX_VALUE);
+          Key stopKey = new Key(encodeLong(row), CF_BYTES, CQ_BYTES, new byte[0], 0);
+          s.setRange(new Range(startKey, stopKey));
 
-        Iterator<Entry<Key,Value>> si = s.iterator();
+          Iterator<Entry<Key,Value>> si = s.iterator();
 
-        if (si.hasNext()) {
-          Entry<Key,Value> e = si.next();
-          Key k = e.getKey();
-          Value v = e.getValue();
+          if (si.hasNext()) {
+            Entry<Key,Value> e = si.next();
+            Key k = e.getKey();
+            Value v = e.getValue();
 
-          checkKeyValue(row, k, v);
+            checkKeyValue(row, k, v);
 
-          if (si.hasNext()) {
-            throw new Exception("ERROR : lookup on " + row + " returned more than one result ");
-          }
+            if (si.hasNext()) {
+              throw new Exception("ERROR : lookup on " + row + " returned more than one result ");
+            }
 
-        } else {
-          throw new Exception("ERROR : lookup on " + row + " failed ");
+          } else {
+            throw new Exception("ERROR : lookup on " + row + " failed ");
+          }
         }
       }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java b/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java
index ae37430b07..e62299722a 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestMultiTableIngest.java
@@ -58,16 +58,17 @@ private static void readBack(Opts opts, ScannerOpts scanOpts, Connector conn, Li
       // wait for table to exist
       while (!conn.tableOperations().exists(table))
         UtilWaitThread.sleep(100);
-      Scanner scanner = conn.createScanner(table, opts.auths);
-      scanner.setBatchSize(scanOpts.scanBatchSize);
-      int count = i;
-      for (Entry<Key,Value> elt : scanner) {
-        String expected = String.format("%06d", count);
-        if (!elt.getKey().getRow().toString().equals(expected))
-          throw new RuntimeException("entry " + elt + " does not match expected " + expected + " in table " + table);
-        count += tableNames.size();
+      try (Scanner scanner = conn.createScanner(table, opts.auths)) {
+        scanner.setBatchSize(scanOpts.scanBatchSize);
+        int count = i;
+        for (Entry<Key,Value> elt : scanner) {
+          String expected = String.format("%06d", count);
+          if (!elt.getKey().getRow().toString().equals(expected))
+            throw new RuntimeException("entry " + elt + " does not match expected " + expected + " in table " + table);
+          count += tableNames.size();
+        }
+        i++;
       }
-      i++;
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
index 05202267fa..7bc3f358aa 100644
--- a/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
+++ b/test/src/main/java/org/apache/accumulo/test/TestRandomDeletes.java
@@ -81,13 +81,13 @@ public String toString() {
   private static TreeSet<RowColumn> scanAll(ClientOnDefaultTable opts, ScannerOpts scanOpts, String tableName) throws Exception {
     TreeSet<RowColumn> result = new TreeSet<>();
     Connector conn = opts.getConnector();
-    Scanner scanner = conn.createScanner(tableName, auths);
-    scanner.setBatchSize(scanOpts.scanBatchSize);
-    for (Entry<Key,Value> entry : scanner) {
-      Key key = entry.getKey();
-      Column column = new Column(TextUtil.getBytes(key.getColumnFamily()), TextUtil.getBytes(key.getColumnQualifier()), TextUtil.getBytes(key
-          .getColumnVisibility()));
-      result.add(new RowColumn(key.getRow(), column, key.getTimestamp()));
+    try (Scanner scanner = conn.createScanner(tableName, auths)) {
+      scanner.setBatchSize(scanOpts.scanBatchSize);
+      for (Entry<Key,Value> entry : scanner) {
+        Key key = entry.getKey();
+        Column column = new Column(TextUtil.getBytes(key.getColumnFamily()), TextUtil.getBytes(key.getColumnQualifier()), TextUtil.getBytes(key.getColumnVisibility()));
+        result.add(new RowColumn(key.getRow(), column, key.getTimestamp()));
+      }
     }
     return result;
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index ebc7686f56..df402370d9 100644
--- a/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -90,39 +90,39 @@ public void test() throws Exception {
 
     log.info("Trace table is online, should be able to find trace");
 
-    final Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY);
-    scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
-    while (true) {
-      final StringBuilder finalBuffer = new StringBuilder();
-      int traceCount = TraceDump.printTrace(scanner, new Printer() {
-        @Override
-        public void print(final String line) {
-          try {
-            finalBuffer.append(line).append("\n");
-          } catch (Exception ex) {
-            throw new RuntimeException(ex);
+    try (Scanner scanner = conn.createScanner("trace", Authorizations.EMPTY)) {
+      scanner.setRange(new Range(new Text(Long.toHexString(root.traceId()))));
+      while (true) {
+        final StringBuilder finalBuffer = new StringBuilder();
+        int traceCount = TraceDump.printTrace(scanner, new Printer() {
+          @Override public void print(final String line) {
+            try {
+              finalBuffer.append(line).append("\n");
+            } catch (Exception ex) {
+              throw new RuntimeException(ex);
+            }
           }
+        });
+        String traceOutput = finalBuffer.toString();
+        log.info("Trace output:{}", traceOutput);
+        if (traceCount > 0) {
+          int lastPos = 0;
+          for (String part : "traceTest,close,binMutations".split(",")) {
+            log.info("Looking in trace output for '{}'", part);
+            int pos = traceOutput.indexOf(part);
+            assertTrue("Did not find '" + part + "' in output", pos > 0);
+            assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
+            lastPos = pos;
+          }
+          break;
+        } else {
+          log.info("Ignoring trace output as traceCount not greater than zero: {}", traceCount);
+          Thread.sleep(1000);
         }
-      });
-      String traceOutput = finalBuffer.toString();
-      log.info("Trace output:{}", traceOutput);
-      if (traceCount > 0) {
-        int lastPos = 0;
-        for (String part : "traceTest,close,binMutations".split(",")) {
-          log.info("Looking in trace output for '{}'", part);
-          int pos = traceOutput.indexOf(part);
-          assertTrue("Did not find '" + part + "' in output", pos > 0);
-          assertTrue("'" + part + "' occurred earlier than the previous element unexpectedly", pos > lastPos);
-          lastPos = pos;
-        }
-        break;
-      } else {
-        log.info("Ignoring trace output as traceCount not greater than zero: {}", traceCount);
-        Thread.sleep(1000);
       }
-    }
-    if (tracer != null) {
-      tracer.destroy();
+      if (tracer != null) {
+        tracer.destroy();
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/UnusedWALIT.java b/test/src/main/java/org/apache/accumulo/test/UnusedWALIT.java
index 281c3587bf..26975bb8e5 100644
--- a/test/src/main/java/org/apache/accumulo/test/UnusedWALIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/UnusedWALIT.java
@@ -109,22 +109,23 @@ public void test() throws Exception {
   }
 
   private void scanSomeData(Connector c, String table, int startRow, int rowCount, int startCol, int colCount) throws Exception {
-    Scanner s = c.createScanner(table, Authorizations.EMPTY);
-    s.setRange(new Range(Integer.toHexString(startRow), Integer.toHexString(startRow + rowCount)));
-    int row = startRow;
-    int col = startCol;
-    for (Entry<Key,Value> entry : s) {
-      assertEquals(row, Integer.parseInt(entry.getKey().getRow().toString(), 16));
-      assertEquals(col++, Integer.parseInt(entry.getKey().getColumnQualifier().toString(), 16));
-      if (col == startCol + colCount) {
-        col = startCol;
-        row++;
-        if (row == startRow + rowCount) {
-          break;
+    try (Scanner s = c.createScanner(table, Authorizations.EMPTY)) {
+      s.setRange(new Range(Integer.toHexString(startRow), Integer.toHexString(startRow + rowCount)));
+      int row = startRow;
+      int col = startCol;
+      for (Entry<Key,Value> entry : s) {
+        assertEquals(row, Integer.parseInt(entry.getKey().getRow().toString(), 16));
+        assertEquals(col++, Integer.parseInt(entry.getKey().getColumnQualifier().toString(), 16));
+        if (col == startCol + colCount) {
+          col = startCol;
+          row++;
+          if (row == startRow + rowCount) {
+            break;
+          }
         }
       }
+      assertEquals(row, startRow + rowCount);
     }
-    assertEquals(row, startRow + rowCount);
   }
 
   private int getWALCount(Instance i, ZooReaderWriter zk) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java b/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
index ddf8ad760e..2b158f4dff 100644
--- a/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
@@ -295,12 +295,11 @@ void writeRandomValue(Connector c, String tableName, int size) throws Exception
 
   private Set<String> getRows(Connector c, String tableName) throws TableNotFoundException {
     Set<String> rows = new HashSet<>();
-    Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-
-    for (Entry<Key,Value> entry : scanner)
-      rows.add(entry.getKey().getRowData().toString());
+    try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> entry : scanner)
+        rows.add(entry.getKey().getRowData().toString());
+    }
     return rows;
-
   }
 
   private void writeFlush(Connector conn, String tablename, String row) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
index 254801f397..5ec6ce97d5 100644
--- a/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
+++ b/test/src/main/java/org/apache/accumulo/test/VerifyIngest.java
@@ -105,118 +105,117 @@ public static void verifyIngest(Connector connector, Opts opts, ScannerOpts scan
         Text colf = new Text(opts.columnFamily);
         Text colq = new Text("col_" + String.format("%07d", expectedCol));
 
-        Scanner scanner = connector.createScanner("test_ingest", labelAuths);
-        scanner.setBatchSize(1);
-        Key startKey = new Key(rowKey, colf, colq);
-        Range range = new Range(startKey, startKey.followingKey(PartialKey.ROW_COLFAM_COLQUAL));
-        scanner.setRange(range);
+        try (Scanner scanner = connector.createScanner("test_ingest", labelAuths)) {
+          scanner.setBatchSize(1);
+          Key startKey = new Key(rowKey, colf, colq);
+          Range range = new Range(startKey, startKey.followingKey(PartialKey.ROW_COLFAM_COLQUAL));
+          scanner.setRange(range);
 
-        byte[] val = null; // t.get(rowKey, column);
+          byte[] val = null; // t.get(rowKey, column);
 
-        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+          Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-        if (iter.hasNext()) {
-          val = iter.next().getValue().get();
-        }
+          if (iter.hasNext()) {
+            val = iter.next().getValue().get();
+          }
 
-        byte ev[];
-        if (opts.random != null) {
-          ev = TestIngest.genRandomValue(random, randomValue, opts.random.intValue(), expectedRow, expectedCol);
-        } else {
-          ev = bytevals[expectedCol % bytevals.length];
-        }
+          byte ev[];
+          if (opts.random != null) {
+            ev = TestIngest.genRandomValue(random, randomValue, opts.random.intValue(), expectedRow, expectedCol);
+          } else {
+            ev = bytevals[expectedCol % bytevals.length];
+          }
 
-        if (val == null) {
-          log.error("Did not find {} {} {}", rowKey, colf, colq);
-          errors++;
-        } else {
-          recsRead++;
-          bytesRead += val.length;
-          Value value = new Value(val);
-          if (value.compareTo(ev) != 0) {
-            log.error("unexpected value  ({} {} {} : saw {} expected {}", rowKey, colf, colq, value, new Value(ev));
+          if (val == null) {
+            log.error("Did not find {} {} {}", rowKey, colf, colq);
             errors++;
+          } else {
+            recsRead++;
+            bytesRead += val.length;
+            Value value = new Value(val);
+            if (value.compareTo(ev) != 0) {
+              log.error("unexpected value  ({} {} {} : saw {} expected {}", rowKey, colf, colq, value, new Value(ev));
+              errors++;
+            }
           }
-        }
 
-        expectedCol++;
-        if (expectedCol >= opts.cols) {
-          expectedCol = 0;
-          expectedRow++;
+          expectedCol++;
+          if (expectedCol >= opts.cols) {
+            expectedCol = 0;
+            expectedRow++;
+          }
         }
-
       } else {
 
         Key startKey = new Key(new Text("row_" + String.format("%010d", expectedRow)));
 
-        Scanner scanner = connector.createScanner(opts.getTableName(), labelAuths);
-        scanner.setBatchSize(scanOpts.scanBatchSize);
-        scanner.setRange(new Range(startKey, endKey));
-        for (int j = 0; j < opts.cols; j++) {
-          scanner.fetchColumn(new Text(opts.columnFamily), new Text("col_" + String.format("%07d", j)));
-        }
+        try (Scanner scanner = connector.createScanner(opts.getTableName(), labelAuths)) {
+          scanner.setBatchSize(scanOpts.scanBatchSize);
+          scanner.setRange(new Range(startKey, endKey));
+          for (int j = 0; j < opts.cols; j++) {
+            scanner.fetchColumn(new Text(opts.columnFamily), new Text("col_" + String.format("%07d", j)));
+          }
 
-        int recsReadBefore = recsRead;
+          int recsReadBefore = recsRead;
 
-        for (Entry<Key,Value> entry : scanner) {
+          for (Entry<Key,Value> entry : scanner) {
 
-          recsRead++;
+            recsRead++;
 
-          bytesRead += entry.getKey().getLength();
-          bytesRead += entry.getValue().getSize();
+            bytesRead += entry.getKey().getLength();
+            bytesRead += entry.getValue().getSize();
 
-          int rowNum = getRow(entry.getKey());
-          int colNum = getCol(entry.getKey());
+            int rowNum = getRow(entry.getKey());
+            int colNum = getCol(entry.getKey());
 
-          if (rowNum != expectedRow) {
-            log.error("rowNum != expectedRow   {} != {}", rowNum, expectedRow);
-            errors++;
-            expectedRow = rowNum;
-          }
+            if (rowNum != expectedRow) {
+              log.error("rowNum != expectedRow   {} != {}", rowNum, expectedRow);
+              errors++;
+              expectedRow = rowNum;
+            }
 
-          if (colNum != expectedCol) {
-            log.error("colNum != expectedCol  {} != {}  rowNum : {}", colNum, expectedCol, rowNum);
-            errors++;
-          }
+            if (colNum != expectedCol) {
+              log.error("colNum != expectedCol  {} != {}  rowNum : {}", colNum, expectedCol, rowNum);
+              errors++;
+            }
 
-          if (expectedRow >= (opts.rows + opts.startRow)) {
-            log.error("expectedRow ({}) >= (ingestArgs.rows + ingestArgs.startRow)  ({}), get batch returned data passed end key", expectedRow,
-                (opts.rows + opts.startRow));
-            errors++;
-            break;
-          }
+            if (expectedRow >= (opts.rows + opts.startRow)) {
+              log.error("expectedRow ({}) >= (ingestArgs.rows + ingestArgs.startRow)  ({}), get batch returned data passed end key", expectedRow, (opts.rows + opts.startRow));
+              errors++;
+              break;
+            }
 
-          byte value[];
-          if (opts.random != null) {
-            value = TestIngest.genRandomValue(random, randomValue, opts.random.intValue(), expectedRow, colNum);
-          } else {
-            value = bytevals[colNum % bytevals.length];
-          }
+            byte value[];
+            if (opts.random != null) {
+              value = TestIngest.genRandomValue(random, randomValue, opts.random.intValue(), expectedRow, colNum);
+            } else {
+              value = bytevals[colNum % bytevals.length];
+            }
 
-          if (entry.getValue().compareTo(value) != 0) {
-            log.error("unexpected value, rowNum : {} colNum : {}", rowNum, colNum);
-            log.error(" saw = {} expected = {}", new String(entry.getValue().get()), new String(value));
-            errors++;
-          }
+            if (entry.getValue().compareTo(value) != 0) {
+              log.error("unexpected value, rowNum : {} colNum : {}", rowNum, colNum);
+              log.error(" saw = {} expected = {}", new String(entry.getValue().get()), new String(value));
+              errors++;
+            }
 
-          if (opts.timestamp >= 0 && entry.getKey().getTimestamp() != opts.timestamp) {
-            log.error("unexpected timestamp {}, rowNum : {} colNum : {}", entry.getKey().getTimestamp(), rowNum, colNum);
-            errors++;
-          }
+            if (opts.timestamp >= 0 && entry.getKey().getTimestamp() != opts.timestamp) {
+              log.error("unexpected timestamp {}, rowNum : {} colNum : {}", entry.getKey().getTimestamp(), rowNum, colNum);
+              errors++;
+            }
 
-          expectedCol++;
-          if (expectedCol >= opts.cols) {
-            expectedCol = 0;
-            expectedRow++;
-          }
+            expectedCol++;
+            if (expectedCol >= opts.cols) {
+              expectedCol = 0;
+              expectedRow++;
+            }
 
-        }
+          }
 
-        if (recsRead == recsReadBefore) {
-          log.warn("Scan returned nothing, breaking...");
-          break;
+          if (recsRead == recsReadBefore) {
+            log.warn("Scan returned nothing, breaking...");
+            break;
+          }
         }
-
       }
     }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java b/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
index 2b72ed8e0e..0d472009c0 100644
--- a/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
@@ -133,10 +133,11 @@ public static void writeAndReadData(Connector connector, String tableName) throw
 
     // Write the data to disk, read it back
     connector.tableOperations().flush(tableName, null, null, true);
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    int i = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      assertEquals("Data read is not data written", rows[i++], entry.getKey().getRow().toString());
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      int i = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        assertEquals("Data read is not data written", rows[i++], entry.getKey().getRow().toString());
+      }
     }
   }
 
@@ -158,31 +159,33 @@ public static void verifyVolumes(Connector connector, String tableName, Range ta
       volumes.add(s);
 
     TreeSet<String> volumesSeen = new TreeSet<>();
-    Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(tableRange);
-    scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
     int fileCount = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      boolean inVolume = false;
-      for (String volume : volumes) {
-        if (entry.getKey().getColumnQualifier().toString().contains(volume)) {
-          volumesSeen.add(volume);
-          inVolume = true;
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(tableRange);
+      scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
+      for (Entry<Key,Value> entry : scanner) {
+        boolean inVolume = false;
+        for (String volume : volumes) {
+          if (entry.getKey().getColumnQualifier().toString().contains(volume)) {
+            volumesSeen.add(volume);
+            inVolume = true;
+          }
         }
+        assertTrue("Data not written to the correct volumes.  " + entry.getKey().getColumnQualifier().toString(), inVolume);
+        fileCount++;
       }
-      assertTrue("Data not written to the correct volumes.  " + entry.getKey().getColumnQualifier().toString(), inVolume);
-      fileCount++;
     }
     assertEquals("Did not see all the volumes. volumes: " + volumes.toString() + " volumes seen: " + volumesSeen.toString(), volumes.size(), volumesSeen.size());
     assertEquals("Wrong number of files", 26, fileCount);
   }
 
   public static void verifyNoVolumes(Connector connector, String tableName, Range tableRange) throws Exception {
-    Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(tableRange);
-    scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
-    for (Entry<Key,Value> entry : scanner) {
-      fail("Data incorrectly written to " + entry.getKey().getColumnQualifier().toString());
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(tableRange);
+      scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
+      for (Entry<Key,Value> entry : scanner) {
+        fail("Data incorrectly written to " + entry.getKey().getColumnQualifier().toString());
+      }
     }
   }
 
@@ -214,17 +217,18 @@ public static void verifyWaLogVolumes(Connector connector, Range tableRange, Str
       volumes.add(s);
 
     TreeSet<String> volumesSeen = new TreeSet<>();
-    Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(tableRange);
-    scanner.fetchColumnFamily(TabletsSection.LogColumnFamily.NAME);
-    for (Entry<Key,Value> entry : scanner) {
-      boolean inVolume = false;
-      for (String volume : volumes) {
-        if (entry.getKey().getColumnQualifier().toString().contains(volume))
-          volumesSeen.add(volume);
-        inVolume = true;
+    try (Scanner scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(tableRange);
+      scanner.fetchColumnFamily(TabletsSection.LogColumnFamily.NAME);
+      for (Entry<Key,Value> entry : scanner) {
+        boolean inVolume = false;
+        for (String volume : volumes) {
+          if (entry.getKey().getColumnQualifier().toString().contains(volume))
+            volumesSeen.add(volume);
+          inVolume = true;
+        }
+        assertTrue("Data not written to the correct volumes.  " + entry.getKey().getColumnQualifier().toString(), inVolume);
       }
-      assertTrue("Data not written to the correct volumes.  " + entry.getKey().getColumnQualifier().toString(), inVolume);
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/VolumeIT.java b/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
index d8073e17f5..93ee31b37c 100644
--- a/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
@@ -140,29 +140,30 @@ public void test() throws Exception {
     bw.close();
     // write the data to disk, read it back
     connector.tableOperations().flush(tableName, null, null, true);
-    Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY);
-    int i = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      assertEquals(rows[i++], entry.getKey().getRow().toString());
-    }
-    // verify the new files are written to the different volumes
-    scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(new Range("1", "1<"));
-    scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
-    int fileCount = 0;
-
-    for (Entry<Key,Value> entry : scanner) {
-      boolean inV1 = entry.getKey().getColumnQualifier().toString().contains(v1.toString());
-      boolean inV2 = entry.getKey().getColumnQualifier().toString().contains(v2.toString());
-      assertTrue(inV1 || inV2);
-      fileCount++;
+    try (Scanner scanner = connector.createScanner(tableName, Authorizations.EMPTY)) {
+      int i = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        assertEquals(rows[i++], entry.getKey().getRow().toString());
+      }
+      // verify the new files are written to the different volumes
+      scanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      scanner.setRange(new Range("1", "1<"));
+      scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
+      int fileCount = 0;
+
+      for (Entry<Key,Value> entry : scanner) {
+        boolean inV1 = entry.getKey().getColumnQualifier().toString().contains(v1.toString());
+        boolean inV2 = entry.getKey().getColumnQualifier().toString().contains(v2.toString());
+        assertTrue(inV1 || inV2);
+        fileCount++;
+      }
+      assertEquals(4, fileCount);
+      List<DiskUsage> diskUsage = connector.tableOperations().getDiskUsage(Collections.singleton(tableName));
+      assertEquals(1, diskUsage.size());
+      long usage = diskUsage.get(0).getUsage().longValue();
+      log.debug("usage {}", usage);
+      assertTrue(usage > 700 && usage < 800);
     }
-    assertEquals(4, fileCount);
-    List<DiskUsage> diskUsage = connector.tableOperations().getDiskUsage(Collections.singleton(tableName));
-    assertEquals(1, diskUsage.size());
-    long usage = diskUsage.get(0).getUsage().longValue();
-    log.debug("usage {}", usage);
-    assertTrue(usage > 700 && usage < 800);
   }
 
   private void verifyData(List<String> expected, Scanner createScanner) {
@@ -177,6 +178,7 @@ private void verifyData(List<String> expected, Scanner createScanner) {
     Collections.sort(expected);
     Collections.sort(actual);
 
+    createScanner.close();
     Assert.assertEquals(expected, actual);
   }
 
@@ -229,40 +231,40 @@ public void testRelativePaths() throws Exception {
 
     connector.securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE);
 
-    Scanner metaScanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
-
-    BatchWriter mbw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
-    for (Entry<Key,Value> entry : metaScanner) {
-      String cq = entry.getKey().getColumnQualifier().toString();
-      if (cq.startsWith(v1.toString())) {
-        Path path = new Path(cq);
-        String relPath = "/" + path.getParent().getName() + "/" + path.getName();
-        Mutation fileMut = new Mutation(entry.getKey().getRow());
-        fileMut.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier());
-        fileMut.put(entry.getKey().getColumnFamily().toString(), relPath, entry.getValue().toString());
-        mbw.addMutation(fileMut);
+    try (Scanner metaScanner = connector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
+
+      BatchWriter mbw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
+
+      for (Entry<Key,Value> entry : metaScanner) {
+        String cq = entry.getKey().getColumnQualifier().toString();
+        if (cq.startsWith(v1.toString())) {
+          Path path = new Path(cq);
+          String relPath = "/" + path.getParent().getName() + "/" + path.getName();
+          Mutation fileMut = new Mutation(entry.getKey().getRow());
+          fileMut.putDelete(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier());
+          fileMut.put(entry.getKey().getColumnFamily().toString(), relPath, entry.getValue().toString());
+          mbw.addMutation(fileMut);
+        }
       }
-    }
 
-    mbw.close();
+      mbw.close();
 
-    connector.tableOperations().online(tableName, true);
+      connector.tableOperations().online(tableName, true);
 
-    verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
+      verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
 
-    connector.tableOperations().compact(tableName, null, null, true, true);
+      connector.tableOperations().compact(tableName, null, null, true, true);
 
-    verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
+      verifyData(expected, connector.createScanner(tableName, Authorizations.EMPTY));
 
-    for (Entry<Key,Value> entry : metaScanner) {
-      String cq = entry.getKey().getColumnQualifier().toString();
-      Path path = new Path(cq);
-      Assert.assertTrue("relative path not deleted " + path.toString(), path.depth() > 2);
+      for (Entry<Key,Value> entry : metaScanner) {
+        String cq = entry.getKey().getColumnQualifier().toString();
+        Path path = new Path(cq);
+        Assert.assertTrue("relative path not deleted " + path.toString(), path.depth() > 2);
+      }
     }
-
   }
 
   @Test
@@ -405,70 +407,73 @@ private void verifyVolumesUsed(String tableName, boolean shouldExist, Path... pa
     verifyData(expected, conn.createScanner(tableName, Authorizations.EMPTY));
 
     Table.ID tableId = Table.ID.of(conn.tableOperations().tableIdMap().get(tableName));
-    Scanner metaScanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(metaScanner);
-    metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
-
-    int counts[] = new int[paths.length];
-
-    outer: for (Entry<Key,Value> entry : metaScanner) {
-      String cf = entry.getKey().getColumnFamily().toString();
-      String cq = entry.getKey().getColumnQualifier().toString();
-
-      String path;
-      if (cf.equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME.toString()))
-        path = cq;
-      else
-        path = entry.getValue().toString();
-
-      for (int i = 0; i < paths.length; i++) {
-        if (path.startsWith(paths[i].toString())) {
-          counts[i]++;
-          continue outer;
+    try (Scanner metaScanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(metaScanner);
+      metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
+
+      int counts[] = new int[paths.length];
+
+      outer:
+      for (Entry<Key,Value> entry : metaScanner) {
+        String cf = entry.getKey().getColumnFamily().toString();
+        String cq = entry.getKey().getColumnQualifier().toString();
+
+        String path;
+        if (cf.equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME.toString()))
+          path = cq;
+        else
+          path = entry.getValue().toString();
+
+        for (int i = 0; i < paths.length; i++) {
+          if (path.startsWith(paths[i].toString())) {
+            counts[i]++;
+            continue outer;
+          }
         }
-      }
 
-      Assert.fail("Unexpected volume " + path);
-    }
+        Assert.fail("Unexpected volume " + path);
+      }
 
-    // keep retrying until WAL state information in ZooKeeper stabilizes or until test times out
-    retry: while (true) {
-      Instance i = conn.getInstance();
-      ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
-      WalStateManager wals = new WalStateManager(i, zk);
-      try {
-        outer: for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) {
-          for (Path path : paths) {
-            if (entry.getKey().toString().startsWith(path.toString())) {
-              continue outer;
+      // keep retrying until WAL state information in ZooKeeper stabilizes or until test times out
+      retry:
+      while (true) {
+        Instance i = conn.getInstance();
+        ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
+        WalStateManager wals = new WalStateManager(i, zk);
+        try {
+          outer:
+          for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) {
+            for (Path path : paths) {
+              if (entry.getKey().toString().startsWith(path.toString())) {
+                continue outer;
+              }
             }
+            log.warn("Unexpected volume " + entry.getKey() + " (" + entry.getValue() + ")");
+            continue retry;
           }
-          log.warn("Unexpected volume " + entry.getKey() + " (" + entry.getValue() + ")");
-          continue retry;
-        }
-      } catch (WalMarkerException e) {
-        Throwable cause = e.getCause();
-        if (cause instanceof NoNodeException) {
-          // ignore WALs being cleaned up
-          continue retry;
+        } catch (WalMarkerException e) {
+          Throwable cause = e.getCause();
+          if (cause instanceof NoNodeException) {
+            // ignore WALs being cleaned up
+            continue retry;
+          }
+          throw e;
         }
-        throw e;
+        break;
       }
-      break;
-    }
-
-    // if a volume is chosen randomly for each tablet, then the probability that a volume will not be chosen for any tablet is ((num_volumes -
-    // 1)/num_volumes)^num_tablets. For 100 tablets and 3 volumes the probability that only 2 volumes would be chosen is 2.46e-18
 
-    int sum = 0;
-    for (int count : counts) {
-      Assert.assertTrue(count > 0);
-      sum += count;
-    }
+      // if a volume is chosen randomly for each tablet, then the probability that a volume will not be chosen for any tablet is ((num_volumes -
+      // 1)/num_volumes)^num_tablets. For 100 tablets and 3 volumes the probability that only 2 volumes would be chosen is 2.46e-18
 
-    Assert.assertEquals(200, sum);
+      int sum = 0;
+      for (int count : counts) {
+        Assert.assertTrue(count > 0);
+        sum += count;
+      }
 
+      Assert.assertEquals(200, sum);
+    }
   }
 
   @Test
diff --git a/test/src/main/java/org/apache/accumulo/test/WaitForBalanceIT.java b/test/src/main/java/org/apache/accumulo/test/WaitForBalanceIT.java
index c6abbce23b..650df2e980 100644
--- a/test/src/main/java/org/apache/accumulo/test/WaitForBalanceIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/WaitForBalanceIT.java
@@ -71,26 +71,27 @@ private boolean isBalanced() throws Exception {
     int offline = 0;
     final Connector c = getConnector();
     for (String tableName : new String[] {MetadataTable.NAME, RootTable.NAME}) {
-      final Scanner s = c.createScanner(tableName, Authorizations.EMPTY);
-      s.setRange(MetadataSchema.TabletsSection.getRange());
-      s.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
-      MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(s);
-      String location = null;
-      for (Entry<Key,Value> entry : s) {
-        Key key = entry.getKey();
-        if (key.getColumnFamily().equals(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME)) {
-          location = key.getColumnQualifier().toString();
-        } else if (MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(key)) {
-          if (location == null) {
-            offline++;
-          } else {
-            Integer count = counts.get(location);
-            if (count == null)
-              count = Integer.valueOf(0);
-            count = Integer.valueOf(count.intValue() + 1);
-            counts.put(location, count);
+      try (Scanner s = c.createScanner(tableName, Authorizations.EMPTY)) {
+        s.setRange(MetadataSchema.TabletsSection.getRange());
+        s.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
+        MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(s);
+        String location = null;
+        for (Entry<Key,Value> entry : s) {
+          Key key = entry.getKey();
+          if (key.getColumnFamily().equals(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME)) {
+            location = key.getColumnQualifier().toString();
+          } else if (MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.hasColumns(key)) {
+            if (location == null) {
+              offline++;
+            } else {
+              Integer count = counts.get(location);
+              if (count == null)
+                count = Integer.valueOf(0);
+              count = Integer.valueOf(count.intValue() + 1);
+              counts.put(location, count);
+            }
+            location = null;
           }
-          location = null;
         }
       }
     }
diff --git a/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java b/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
index 07a7c40f2d..f278624c3f 100644
--- a/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
@@ -75,36 +75,37 @@ public void testScan() throws Exception {
 
     log.info("Creating scanner");
     // make a scanner for a table with 10 keys
-    final Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-    final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
-    scanner.addScanIterator(cfg);
-
-    log.info("iterating");
-    Iterator<Map.Entry<Key,Value>> it = scanner.iterator();
-    int keyCount = 0;
-    int yieldNextCount = 0;
-    int yieldSeekCount = 0;
-    while (it.hasNext()) {
-      Map.Entry<Key,Value> next = it.next();
-      log.info(Integer.toString(keyCount) + ": Got key " + next.getKey() + " with value " + next.getValue());
-
-      // verify we got the expected key
-      char expected = (char) (START_ROW + keyCount);
-      Assert.assertEquals("Unexpected row", Character.toString(expected), next.getKey().getRow().toString());
-
-      // determine whether we yielded on a next and seek
-      if ((keyCount & 1) != 0) {
-        yieldNextCount++;
-        yieldSeekCount++;
+    try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+      final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
+      scanner.addScanIterator(cfg);
+
+      log.info("iterating");
+      Iterator<Map.Entry<Key,Value>> it = scanner.iterator();
+      int keyCount = 0;
+      int yieldNextCount = 0;
+      int yieldSeekCount = 0;
+      while (it.hasNext()) {
+        Map.Entry<Key,Value> next = it.next();
+        log.info(Integer.toString(keyCount) + ": Got key " + next.getKey() + " with value " + next.getValue());
+
+        // verify we got the expected key
+        char expected = (char) (START_ROW + keyCount);
+        Assert.assertEquals("Unexpected row", Character.toString(expected), next.getKey().getRow().toString());
+
+        // determine whether we yielded on a next and seek
+        if ((keyCount & 1) != 0) {
+          yieldNextCount++;
+          yieldSeekCount++;
+        }
+        String[] value = StringUtils.split(next.getValue().toString(), ',');
+        Assert.assertEquals("Unexpected yield next count", Integer.toString(yieldNextCount), value[0]);
+        Assert.assertEquals("Unexpected yield seek count", Integer.toString(yieldSeekCount), value[1]);
+        Assert.assertEquals("Unexpected rebuild count", Integer.toString(yieldNextCount + yieldSeekCount), value[2]);
+
+        keyCount++;
       }
-      String[] value = StringUtils.split(next.getValue().toString(), ',');
-      Assert.assertEquals("Unexpected yield next count", Integer.toString(yieldNextCount), value[0]);
-      Assert.assertEquals("Unexpected yield seek count", Integer.toString(yieldSeekCount), value[1]);
-      Assert.assertEquals("Unexpected rebuild count", Integer.toString(yieldNextCount + yieldSeekCount), value[2]);
-
-      keyCount++;
+      Assert.assertEquals("Did not get the expected number of results", 10, keyCount);
     }
-    Assert.assertEquals("Did not get the expected number of results", 10, keyCount);
   }
 
   @Test
@@ -125,37 +126,38 @@ public void testBatchScan() throws Exception {
 
     log.info("Creating batch scanner");
     // make a scanner for a table with 10 keys
-    final BatchScanner scanner = conn.createBatchScanner(tableName, Authorizations.EMPTY, 1);
-    final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
-    scanner.addScanIterator(cfg);
-    scanner.setRanges(Collections.singleton(new Range()));
-
-    log.info("iterating");
-    Iterator<Map.Entry<Key,Value>> it = scanner.iterator();
-    int keyCount = 0;
-    int yieldNextCount = 0;
-    int yieldSeekCount = 0;
-    while (it.hasNext()) {
-      Map.Entry<Key,Value> next = it.next();
-      log.info(Integer.toString(keyCount) + ": Got key " + next.getKey() + " with value " + next.getValue());
-
-      // verify we got the expected key
-      char expected = (char) (START_ROW + keyCount);
-      Assert.assertEquals("Unexpected row", Character.toString(expected), next.getKey().getRow().toString());
-
-      // determine whether we yielded on a next and seek
-      if ((keyCount & 1) != 0) {
-        yieldNextCount++;
-        yieldSeekCount++;
+    try (BatchScanner scanner = conn.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+      final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
+      scanner.addScanIterator(cfg);
+      scanner.setRanges(Collections.singleton(new Range()));
+
+      log.info("iterating");
+      Iterator<Map.Entry<Key,Value>> it = scanner.iterator();
+      int keyCount = 0;
+      int yieldNextCount = 0;
+      int yieldSeekCount = 0;
+      while (it.hasNext()) {
+        Map.Entry<Key,Value> next = it.next();
+        log.info(Integer.toString(keyCount) + ": Got key " + next.getKey() + " with value " + next.getValue());
+
+        // verify we got the expected key
+        char expected = (char) (START_ROW + keyCount);
+        Assert.assertEquals("Unexpected row", Character.toString(expected), next.getKey().getRow().toString());
+
+        // determine whether we yielded on a next and seek
+        if ((keyCount & 1) != 0) {
+          yieldNextCount++;
+          yieldSeekCount++;
+        }
+        String[] value = StringUtils.split(next.getValue().toString(), ',');
+        Assert.assertEquals("Unexpected yield next count", Integer.toString(yieldNextCount), value[0]);
+        Assert.assertEquals("Unexpected yield seek count", Integer.toString(yieldSeekCount), value[1]);
+        Assert.assertEquals("Unexpected rebuild count", Integer.toString(yieldNextCount + yieldSeekCount), value[2]);
+
+        keyCount++;
       }
-      String[] value = StringUtils.split(next.getValue().toString(), ',');
-      Assert.assertEquals("Unexpected yield next count", Integer.toString(yieldNextCount), value[0]);
-      Assert.assertEquals("Unexpected yield seek count", Integer.toString(yieldSeekCount), value[1]);
-      Assert.assertEquals("Unexpected rebuild count", Integer.toString(yieldNextCount + yieldSeekCount), value[2]);
-
-      keyCount++;
+      Assert.assertEquals("Did not get the expected number of results", 10, keyCount);
     }
-    Assert.assertEquals("Did not get the expected number of results", 10, keyCount);
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT.java
index 7c5babe889..c6222767ee 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/AddSplitIT.java
@@ -94,36 +94,36 @@ public void addSplitTest() throws Exception {
   }
 
   private void verifyData(String tableName, long ts) throws Exception {
-    Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
+    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
 
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-    for (int i = 0; i < 10000; i++) {
-      if (!iter.hasNext()) {
-        throw new Exception("row " + i + " not found");
-      }
+      for (int i = 0; i < 10000; i++) {
+        if (!iter.hasNext()) {
+          throw new Exception("row " + i + " not found");
+        }
 
-      Entry<Key,Value> entry = iter.next();
+        Entry<Key,Value> entry = iter.next();
 
-      String row = String.format("%09d", i);
+        String row = String.format("%09d", i);
 
-      if (!entry.getKey().getRow().equals(new Text(row))) {
-        throw new Exception("unexpected row " + entry.getKey() + " " + i);
-      }
+        if (!entry.getKey().getRow().equals(new Text(row))) {
+          throw new Exception("unexpected row " + entry.getKey() + " " + i);
+        }
 
-      if (entry.getKey().getTimestamp() != ts) {
-        throw new Exception("unexpected ts " + entry.getKey() + " " + ts);
-      }
+        if (entry.getKey().getTimestamp() != ts) {
+          throw new Exception("unexpected ts " + entry.getKey() + " " + ts);
+        }
 
-      if (Integer.parseInt(entry.getValue().toString()) != i) {
-        throw new Exception("unexpected value " + entry + " " + i);
+        if (Integer.parseInt(entry.getValue().toString()) != i) {
+          throw new Exception("unexpected value " + entry + " " + i);
+        }
       }
-    }
 
-    if (iter.hasNext()) {
-      throw new Exception("found more than expected " + iter.next());
+      if (iter.hasNext()) {
+        throw new Exception("found more than expected " + iter.next());
+      }
     }
-
   }
 
   private void insertData(String tableName, long ts) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java
index 0d60cce2ec..8d0edb5ebc 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BadIteratorMincIT.java
@@ -68,41 +68,42 @@ public void test() throws Exception {
     FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
 
     // try to scan table
-    Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-    int count = Iterators.size(scanner.iterator());
-    assertEquals("Did not see expected # entries " + count, 1, count);
+    try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
+      int count = Iterators.size(scanner.iterator());
+      assertEquals("Did not see expected # entries " + count, 1, count);
 
-    // remove the bad iterator
-    c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc));
+      // remove the bad iterator
+      c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc));
 
-    sleepUninterruptibly(5, TimeUnit.SECONDS);
+      sleepUninterruptibly(5, TimeUnit.SECONDS);
 
-    // minc should complete
-    FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
+      // minc should complete
+      FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
 
-    count = Iterators.size(scanner.iterator());
+      count = Iterators.size(scanner.iterator());
 
-    if (count != 1)
-      throw new Exception("Did not see expected # entries " + count);
+      if (count != 1)
+        throw new Exception("Did not see expected # entries " + count);
 
-    // now try putting bad iterator back and deleting the table
-    c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
-    bw = c.createBatchWriter(tableName, new BatchWriterConfig());
-    m = new Mutation(new Text("r2"));
-    m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
-    bw.addMutation(m);
-    bw.close();
+      // now try putting bad iterator back and deleting the table
+      c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
+      bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+      m = new Mutation(new Text("r2"));
+      m.put(new Text("acf"), new Text(tableName), new Value("1".getBytes(UTF_8)));
+      bw.addMutation(m);
+      bw.close();
 
-    // make sure property is given time to propagate
-    sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+      // make sure property is given time to propagate
+      sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
 
-    c.tableOperations().flush(tableName, null, null, false);
+      c.tableOperations().flush(tableName, null, null, false);
 
-    // make sure the flush has time to start
-    sleepUninterruptibly(1, TimeUnit.SECONDS);
+      // make sure the flush has time to start
+      sleepUninterruptibly(1, TimeUnit.SECONDS);
 
-    // this should not hang
-    c.tableOperations().delete(tableName);
+      // this should not hang
+      c.tableOperations().delete(tableName);
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
index a3add3de86..19a50aa8d8 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
@@ -102,25 +102,25 @@ public void test() throws Exception {
     HashMap<Text,Value> found = new HashMap<>();
 
     for (int i = 0; i < 20; i++) {
-      BatchScanner bs = getConnector().createBatchScanner(tableName, Authorizations.EMPTY, 4);
+      try (BatchScanner bs = getConnector().createBatchScanner(tableName, Authorizations.EMPTY, 4)) {
 
-      found.clear();
+        found.clear();
 
-      long t1 = System.currentTimeMillis();
+        long t1 = System.currentTimeMillis();
 
-      bs.setRanges(ranges);
+        bs.setRanges(ranges);
 
-      for (Entry<Key,Value> entry : bs) {
-        found.put(entry.getKey().getRow(), entry.getValue());
-      }
-      bs.close();
+        for (Entry<Key,Value> entry : bs) {
+          found.put(entry.getKey().getRow(), entry.getValue());
+        }
 
-      long t2 = System.currentTimeMillis();
+        long t2 = System.currentTimeMillis();
 
-      log.info(String.format("rate : %06.2f%n", ranges.size() / ((t2 - t1) / 1000.0)));
+        log.info(String.format("rate : %06.2f%n", ranges.size() / ((t2 - t1) / 1000.0)));
 
-      if (!found.equals(expected))
-        throw new Exception("Found and expected differ " + found + " " + expected);
+        if (!found.equals(expected))
+          throw new Exception("Found and expected differ " + found + " " + expected);
+      }
     }
 
     splits = getConnector().tableOperations().listSplits(tableName);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java
index ea048672e8..38649e59e8 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BatchWriterFlushIT.java
@@ -76,8 +76,8 @@ public void run() throws Exception {
 
   private void runLatencyTest(String tableName) throws Exception {
     // should automatically flush after 2 seconds
-    try (BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig().setMaxLatency(1000, TimeUnit.MILLISECONDS))) {
-      Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
+    try (BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig().setMaxLatency(1000, TimeUnit.MILLISECONDS));
+        Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
 
       Mutation m = new Mutation(new Text(String.format("r_%10d", 1)));
       m.put(new Text("cf"), new Text("cq"), new Value("1".getBytes(UTF_8)));
@@ -104,72 +104,73 @@ private void runLatencyTest(String tableName) throws Exception {
   private void runFlushTest(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException,
       Exception {
     BatchWriter bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
-    Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
-    Random r = new Random();
+    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
+      Random r = new Random();
 
-    for (int i = 0; i < 4; i++) {
-      for (int j = 0; j < NUM_TO_FLUSH; j++) {
-        int row = i * NUM_TO_FLUSH + j;
+      for (int i = 0; i < 4; i++) {
+        for (int j = 0; j < NUM_TO_FLUSH; j++) {
+          int row = i * NUM_TO_FLUSH + j;
 
-        Mutation m = new Mutation(new Text(String.format("r_%10d", row)));
-        m.put(new Text("cf"), new Text("cq"), new Value(("" + row).getBytes()));
-        bw.addMutation(m);
-      }
+          Mutation m = new Mutation(new Text(String.format("r_%10d", row)));
+          m.put(new Text("cf"), new Text("cq"), new Value(("" + row).getBytes()));
+          bw.addMutation(m);
+        }
 
-      bw.flush();
+        bw.flush();
 
-      // do a few random lookups into the data just flushed
+        // do a few random lookups into the data just flushed
 
-      for (int k = 0; k < 10; k++) {
-        int rowToLookup = r.nextInt(NUM_TO_FLUSH) + i * NUM_TO_FLUSH;
+        for (int k = 0; k < 10; k++) {
+          int rowToLookup = r.nextInt(NUM_TO_FLUSH) + i * NUM_TO_FLUSH;
 
-        scanner.setRange(new Range(new Text(String.format("r_%10d", rowToLookup))));
+          scanner.setRange(new Range(new Text(String.format("r_%10d", rowToLookup))));
 
-        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+          Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-        if (!iter.hasNext())
-          throw new Exception(" row " + rowToLookup + " not found after flush");
+          if (!iter.hasNext())
+            throw new Exception(" row " + rowToLookup + " not found after flush");
 
-        Entry<Key,Value> entry = iter.next();
+          Entry<Key,Value> entry = iter.next();
 
-        if (iter.hasNext())
-          throw new Exception("Scanner returned too much");
+          if (iter.hasNext())
+            throw new Exception("Scanner returned too much");
 
-        verifyEntry(rowToLookup, entry);
-      }
+          verifyEntry(rowToLookup, entry);
+        }
 
-      // scan all data just flushed
-      scanner.setRange(new Range(new Text(String.format("r_%10d", i * NUM_TO_FLUSH)), true, new Text(String.format("r_%10d", (i + 1) * NUM_TO_FLUSH)), false));
-      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+        // scan all data just flushed
+        scanner.setRange(new Range(new Text(String.format("r_%10d", i * NUM_TO_FLUSH)), true, new Text(String.format("r_%10d", (i + 1) * NUM_TO_FLUSH)), false));
+        Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-      for (int j = 0; j < NUM_TO_FLUSH; j++) {
-        int row = i * NUM_TO_FLUSH + j;
+        for (int j = 0; j < NUM_TO_FLUSH; j++) {
+          int row = i * NUM_TO_FLUSH + j;
 
-        if (!iter.hasNext())
-          throw new Exception("Scan stopped permaturely at " + row);
+          if (!iter.hasNext())
+            throw new Exception("Scan stopped permaturely at " + row);
 
-        Entry<Key,Value> entry = iter.next();
+          Entry<Key,Value> entry = iter.next();
 
-        verifyEntry(row, entry);
-      }
+          verifyEntry(row, entry);
+        }
 
-      if (iter.hasNext())
-        throw new Exception("Scanner returned too much");
+        if (iter.hasNext())
+          throw new Exception("Scanner returned too much");
 
-    }
+      }
 
-    bw.close();
+      bw.close();
 
-    // test adding a mutation to a closed batch writer
-    boolean caught = false;
-    try {
-      bw.addMutation(new Mutation(new Text("foobar")));
-    } catch (IllegalStateException ise) {
-      caught = true;
-    }
+      // test adding a mutation to a closed batch writer
+      boolean caught = false;
+      try {
+        bw.addMutation(new Mutation(new Text("foobar")));
+      } catch (IllegalStateException ise) {
+        caught = true;
+      }
 
-    if (!caught) {
-      throw new Exception("Adding to closed batch writer did not fail");
+      if (!caught) {
+        throw new Exception("Adding to closed batch writer did not fail");
+      }
     }
   }
 
@@ -230,25 +231,25 @@ public void run() {
     threads.shutdown();
     threads.awaitTermination(3, TimeUnit.MINUTES);
     bw.close();
-    Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
-    for (Entry<Key,Value> e : scanner) {
-      Mutation m = new Mutation(e.getKey().getRow());
-      m.put(e.getKey().getColumnFamily(), e.getKey().getColumnQualifier(), e.getValue());
-      boolean found = false;
-      for (int l = 0; l < NUM_THREADS; l++) {
-        if (allMuts.get(l).contains(m)) {
-          found = true;
-          allMuts.get(l).remove(m);
-          break;
+    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> e : scanner) {
+        Mutation m = new Mutation(e.getKey().getRow());
+        m.put(e.getKey().getColumnFamily(), e.getKey().getColumnQualifier(), e.getValue());
+        boolean found = false;
+        for (int l = 0; l < NUM_THREADS; l++) {
+          if (allMuts.get(l).contains(m)) {
+            found = true;
+            allMuts.get(l).remove(m);
+            break;
+          }
         }
+        Assert.assertTrue("Mutation not found: " + m.toString(), found);
       }
-      Assert.assertTrue("Mutation not found: " + m.toString(), found);
-    }
 
-    for (int m = 0; m < NUM_THREADS; m++) {
-      Assert.assertEquals(0, allMuts.get(m).size());
+      for (int m = 0; m < NUM_THREADS; m++) {
+        Assert.assertEquals(0, allMuts.get(m).size());
+      }
     }
-
   }
 
   private void verifyEntry(int row, Entry<Key,Value> entry) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java
index 9ce221a648..9babde08fc 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BinaryStressIT.java
@@ -96,10 +96,11 @@ public void binaryStressTest() throws Exception {
     BinaryIT.runTest(c, tableName);
     String id = c.tableOperations().tableIdMap().get(tableName);
     Set<Text> tablets = new HashSet<>();
-    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(Range.prefix(id));
-    for (Entry<Key,Value> entry : s) {
-      tablets.add(entry.getKey().getRow());
+    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(Range.prefix(id));
+      for (Entry<Key,Value> entry : s) {
+        tablets.add(entry.getKey().getRow());
+      }
     }
     assertTrue("Expected at least 8 tablets, saw " + tablets.size(), tablets.size() > 7);
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
index 1c6fc9fa73..811d25b20e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
@@ -147,11 +147,12 @@ public void test() throws Exception {
       timeCheck(t1 + t2 + t3, tb1 + tb2 + tb3);
 
       // test querying for empty key
-      Scanner scanner = c.createScanner(tables[3], Authorizations.EMPTY);
-      scanner.setRange(new Range(new Text("")));
+      try (Scanner scanner = c.createScanner(tables[3], Authorizations.EMPTY)) {
+        scanner.setRange(new Range(new Text("")));
 
-      if (!scanner.iterator().next().getValue().toString().equals("foo1")) {
-        throw new Exception("Did not see foo1");
+        if (!scanner.iterator().next().getValue().toString().equals("foo1")) {
+          throw new Exception("Did not see foo1");
+        }
       }
     } finally {
       c.instanceOperations().setProperty(Property.TSERV_READ_AHEAD_MAXCONCURRENT.getKey(), readAhead);
@@ -201,25 +202,24 @@ private long query(Connector c, String table, int depth, long start, long end, i
       ranges.add(range);
     }
 
-    BatchScanner bs = c.createBatchScanner(table, Authorizations.EMPTY, 1);
-    bs.setRanges(ranges);
+    try (BatchScanner bs = c.createBatchScanner(table, Authorizations.EMPTY, 1)) {
+      bs.setRanges(ranges);
 
-    long t1 = System.currentTimeMillis();
-    for (Entry<Key,Value> entry : bs) {
-      long v = Long.parseLong(entry.getValue().toString());
-      if (!expected.remove(v)) {
-        throw new Exception("Got unexpected return " + entry.getKey() + " " + entry.getValue());
+      long t1 = System.currentTimeMillis();
+      for (Entry<Key,Value> entry : bs) {
+        long v = Long.parseLong(entry.getValue().toString());
+        if (!expected.remove(v)) {
+          throw new Exception("Got unexpected return " + entry.getKey() + " " + entry.getValue());
+        }
       }
-    }
-    long t2 = System.currentTimeMillis();
-
-    if (expected.size() > 0) {
-      throw new Exception("Did not get all expected values " + expected.size());
-    }
+      long t2 = System.currentTimeMillis();
 
-    bs.close();
+      if (expected.size() > 0) {
+        throw new Exception("Did not get all expected values " + expected.size());
+      }
 
-    return t2 - t1;
+      return t2 - t1;
+    }
   }
 
   private void write(Connector c, String table, int depth, long start, long end, int step) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BulkFileIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BulkFileIT.java
index 87b3d5ac67..e909fdc6e0 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BulkFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BulkFileIT.java
@@ -101,27 +101,28 @@ public void testBulkFile() throws Exception {
   }
 
   private void verifyData(String table, int s, int e) throws Exception {
-    Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY);
+    try (Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY)) {
 
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-    for (int i = s; i <= e; i++) {
-      if (!iter.hasNext())
-        throw new Exception("row " + i + " not found");
+      for (int i = s; i <= e; i++) {
+        if (!iter.hasNext())
+          throw new Exception("row " + i + " not found");
 
-      Entry<Key,Value> entry = iter.next();
+        Entry<Key,Value> entry = iter.next();
 
-      String row = String.format("%04d", i);
+        String row = String.format("%04d", i);
 
-      if (!entry.getKey().getRow().equals(new Text(row)))
-        throw new Exception("unexpected row " + entry.getKey() + " " + i);
+        if (!entry.getKey().getRow().equals(new Text(row)))
+          throw new Exception("unexpected row " + entry.getKey() + " " + i);
 
-      if (Integer.parseInt(entry.getValue().toString()) != i)
-        throw new Exception("unexpected value " + entry + " " + i);
-    }
+        if (Integer.parseInt(entry.getValue().toString()) != i)
+          throw new Exception("unexpected value " + entry + " " + i);
+      }
 
-    if (iter.hasNext())
-      throw new Exception("found more than expected " + iter.next());
+      if (iter.hasNext())
+        throw new Exception("found more than expected " + iter.next());
+    }
   }
 
   private void writeData(FileSKVWriter w, int s, int e) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
index 22ac6a7304..7c4a6a82ae 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ClassLoaderIT.java
@@ -112,12 +112,13 @@ public void test() throws Exception {
   }
 
   private void scanCheck(Connector c, String tableName, String expected) throws Exception {
-    Scanner bs = c.createScanner(tableName, Authorizations.EMPTY);
-    Iterator<Entry<Key,Value>> iterator = bs.iterator();
-    assertTrue(iterator.hasNext());
-    Entry<Key,Value> next = iterator.next();
-    assertFalse(iterator.hasNext());
-    assertEquals(expected, next.getValue().toString());
+    try (Scanner bs = c.createScanner(tableName, Authorizations.EMPTY)) {
+      Iterator<Entry<Key,Value>> iterator = bs.iterator();
+      assertTrue(iterator.hasNext());
+      Entry<Key,Value> next = iterator.next();
+      assertFalse(iterator.hasNext());
+      assertEquals(expected, next.getValue().toString());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CleanTmpIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CleanTmpIT.java
index 751e827953..83e5a3561e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CleanTmpIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CleanTmpIT.java
@@ -87,11 +87,13 @@ public void test() throws Exception {
 
     // create a fake _tmp file in its directory
     String id = c.tableOperations().tableIdMap().get(tableName);
-    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(Range.prefix(id));
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    Path file = new Path(entry.getKey().getColumnQualifier().toString());
+    Path file;
+    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.setRange(Range.prefix(id));
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      file = new Path(entry.getKey().getColumnQualifier().toString());
+    }
 
     FileSystem fs = getCluster().getFileSystem();
     assertTrue("Could not find file: " + file, fs.exists(file));
@@ -104,9 +106,10 @@ public void test() throws Exception {
     getCluster().stop();
     getCluster().start();
 
-    Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-    assertEquals(2, Iterators.size(scanner.iterator()));
-    // If we performed log recovery, we should have cleaned up any stray files
-    assertFalse("File still exists: " + tmp, fs.exists(tmp));
+    try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
+      assertEquals(2, Iterators.size(scanner.iterator()));
+      // If we performed log recovery, we should have cleaned up any stray files
+      assertFalse("File still exists: " + tmp, fs.exists(tmp));
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CleanUpIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CleanUpIT.java
index 2ff55e835e..d240b570ec 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CleanUpIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CleanUpIT.java
@@ -75,61 +75,62 @@ public void run() throws Exception {
 
     bw.flush();
 
-    Scanner scanner = getConnector().createScanner(tableName, new Authorizations());
+    try (Scanner scanner = getConnector().createScanner(tableName, new Authorizations())) {
 
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      count++;
-      if (!entry.getValue().toString().equals("5")) {
-        Assert.fail("Unexpected value " + entry.getValue());
+      int count = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        count++;
+        if (!entry.getValue().toString().equals("5")) {
+          Assert.fail("Unexpected value " + entry.getValue());
+        }
       }
-    }
 
-    Assert.assertEquals("Unexpected count", 1, count);
+      Assert.assertEquals("Unexpected count", 1, count);
 
-    int threadCount = countThreads();
-    if (threadCount < 2) {
-      printThreadNames();
-      Assert.fail("Not seeing expected threads. Saw " + threadCount);
-    }
-
-    CleanUp.shutdownNow();
+      int threadCount = countThreads();
+      if (threadCount < 2) {
+        printThreadNames();
+        Assert.fail("Not seeing expected threads. Saw " + threadCount);
+      }
 
-    Mutation m2 = new Mutation("r2");
-    m2.put("cf1", "cq1", 1, "6");
+      CleanUp.shutdownNow();
 
-    try {
-      bw.addMutation(m1);
-      bw.flush();
-      Assert.fail("batch writer did not fail");
-    } catch (Exception e) {
+      Mutation m2 = new Mutation("r2");
+      m2.put("cf1", "cq1", 1, "6");
 
-    }
+      try {
+        bw.addMutation(m1);
+        bw.flush();
+        Assert.fail("batch writer did not fail");
+      } catch (Exception e) {
 
-    try {
-      // expect this to fail also, want to clean up batch writer threads
-      bw.close();
-      Assert.fail("batch writer close not fail");
-    } catch (Exception e) {
+      }
 
-    }
+      try {
+        // expect this to fail also, want to clean up batch writer threads
+        bw.close();
+        Assert.fail("batch writer close not fail");
+      } catch (Exception e) {
 
-    try {
-      count = 0;
-      Iterator<Entry<Key,Value>> iter = scanner.iterator();
-      while (iter.hasNext()) {
-        iter.next();
-        count++;
       }
-      Assert.fail("scanner did not fail");
-    } catch (Exception e) {
 
-    }
+      try {
+        count = 0;
+        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+        while (iter.hasNext()) {
+          iter.next();
+          count++;
+        }
+        Assert.fail("scanner did not fail");
+      } catch (Exception e) {
 
-    threadCount = countThreads();
-    if (threadCount > 0) {
-      printThreadNames();
-      Assert.fail("Threads did not go away. Saw " + threadCount);
+      }
+
+      threadCount = countThreads();
+      if (threadCount > 0) {
+        printThreadNames();
+        Assert.fail("Threads did not go away. Saw " + threadCount);
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
index 64cdc34d17..a088354e75 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
@@ -116,60 +116,61 @@ public void testProps() throws Exception {
   }
 
   private void checkData(String table2, Connector c) throws TableNotFoundException {
-    Scanner scanner = c.createScanner(table2, Authorizations.EMPTY);
+    try (Scanner scanner = c.createScanner(table2, Authorizations.EMPTY)) {
 
-    HashMap<String,String> expected = new HashMap<>();
-    expected.put("001:x", "9");
-    expected.put("001:y", "7");
-    expected.put("008:x", "3");
-    expected.put("008:y", "4");
+      HashMap<String,String> expected = new HashMap<>();
+      expected.put("001:x", "9");
+      expected.put("001:y", "7");
+      expected.put("008:x", "3");
+      expected.put("008:y", "4");
 
-    HashMap<String,String> actual = new HashMap<>();
+      HashMap<String,String> actual = new HashMap<>();
 
-    for (Entry<Key,Value> entry : scanner)
-      actual.put(entry.getKey().getRowData().toString() + ":" + entry.getKey().getColumnQualifierData().toString(), entry.getValue().toString());
+      for (Entry<Key,Value> entry : scanner)
+        actual.put(entry.getKey().getRowData().toString() + ":" + entry.getKey().getColumnQualifierData().toString(), entry.getValue().toString());
 
-    Assert.assertEquals(expected, actual);
+      Assert.assertEquals(expected, actual);
+    }
   }
 
   private void checkMetadata(String table, Connector conn) throws Exception {
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(s);
-    String tableId = conn.tableOperations().tableIdMap().get(table);
-
-    Assert.assertNotNull("Could not get table id for " + table, tableId);
-
-    s.setRange(Range.prefix(tableId));
-
-    Key k;
-    Text cf = new Text(), cq = new Text();
-    int itemsInspected = 0;
-    for (Entry<Key,Value> entry : s) {
-      itemsInspected++;
-      k = entry.getKey();
-      k.getColumnFamily(cf);
-      k.getColumnQualifier(cq);
-
-      if (cf.equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
-        Path p = new Path(cq.toString());
-        FileSystem fs = cluster.getFileSystem();
-        Assert.assertTrue("File does not exist: " + p, fs.exists(p));
-      } else if (cf.equals(MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnFamily())) {
-        Assert.assertEquals("Saw unexpected cq", MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnQualifier(), cq);
-        Path tabletDir = new Path(entry.getValue().toString());
-        Path tableDir = tabletDir.getParent();
-        Path tablesDir = tableDir.getParent();
-
-        Assert.assertEquals(ServerConstants.TABLE_DIR, tablesDir.getName());
-      } else {
-        Assert.fail("Got unexpected key-value: " + entry);
-        throw new RuntimeException();
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(s);
+      String tableId = conn.tableOperations().tableIdMap().get(table);
+
+      Assert.assertNotNull("Could not get table id for " + table, tableId);
+
+      s.setRange(Range.prefix(tableId));
+
+      Key k;
+      Text cf = new Text(), cq = new Text();
+      int itemsInspected = 0;
+      for (Entry<Key,Value> entry : s) {
+        itemsInspected++;
+        k = entry.getKey();
+        k.getColumnFamily(cf);
+        k.getColumnQualifier(cq);
+
+        if (cf.equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
+          Path p = new Path(cq.toString());
+          FileSystem fs = cluster.getFileSystem();
+          Assert.assertTrue("File does not exist: " + p, fs.exists(p));
+        } else if (cf.equals(MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnFamily())) {
+          Assert.assertEquals("Saw unexpected cq", MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnQualifier(), cq);
+          Path tabletDir = new Path(entry.getValue().toString());
+          Path tableDir = tabletDir.getParent();
+          Path tablesDir = tableDir.getParent();
+
+          Assert.assertEquals(ServerConstants.TABLE_DIR, tablesDir.getName());
+        } else {
+          Assert.fail("Got unexpected key-value: " + entry);
+          throw new RuntimeException();
+        }
       }
+      Assert.assertTrue("Expected to find metadata entries", itemsInspected > 0);
     }
-
-    Assert.assertTrue("Expected to find metadata entries", itemsInspected > 0);
   }
 
   private BatchWriter writeData(String table1, Connector c) throws TableNotFoundException, MutationsRejectedException {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CombinerIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CombinerIT.java
index d4ef18ea2f..9ffa9f910e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CombinerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CombinerIT.java
@@ -46,12 +46,13 @@ protected int defaultTimeoutSeconds() {
   }
 
   private void checkSum(String tableName, Connector c) throws Exception {
-    Scanner s = c.createScanner(tableName, Authorizations.EMPTY);
-    Iterator<Entry<Key,Value>> i = s.iterator();
-    assertTrue(i.hasNext());
-    Entry<Key,Value> entry = i.next();
-    assertEquals("45", entry.getValue().toString());
-    assertFalse(i.hasNext());
+    try (Scanner s = c.createScanner(tableName, Authorizations.EMPTY)) {
+      Iterator<Entry<Key,Value>> i = s.iterator();
+      assertTrue(i.hasNext());
+      Entry<Key,Value> entry = i.next();
+      assertEquals("45", entry.getValue().toString());
+      assertFalse(i.hasNext());
+    }
   }
 
   @Test
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
index e5fecf86e9..afe72b10f0 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CompactionIT.java
@@ -177,10 +177,11 @@ public void run() {
   }
 
   private int countFiles(Connector c) throws Exception {
-    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(new Text(MetadataSchema.TabletsSection.TabletColumnFamily.NAME));
-    s.fetchColumnFamily(new Text(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME));
-    return Iterators.size(s.iterator());
+    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(new Text(MetadataSchema.TabletsSection.TabletColumnFamily.NAME));
+      s.fetchColumnFamily(new Text(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME));
+      return Iterators.size(s.iterator());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
index 087b4125f2..c9ecaed748 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
@@ -58,6 +58,7 @@
       IteratorSetting slow = new IteratorSetting(30, "slow", SlowIterator.class);
       SlowIterator.setSleepTime(slow, time);
       scanner.addScanIterator(slow);
+      scanner.close();
     }
 
     @Override
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java
index d812914410..e3ca3864b9 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConfigurableCompactionIT.java
@@ -164,9 +164,10 @@ private void runTest(final Connector c, final String tableName, final int n) thr
   }
 
   private int countFiles(Connector c, String tableName) throws Exception {
-    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    return Iterators.size(s.iterator());
+    try (Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      return Iterators.size(s.iterator());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
index 7b92951f55..ce4cb2b078 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
@@ -138,106 +138,103 @@ private void test1(String tableName) throws Exception {
     }
 
     // verify mutation did not go through
-    Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new Range(new Text("r1")));
+    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new Range(new Text("r1")));
 
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    Entry<Key,Value> entry = iter.next();
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      Entry<Key,Value> entry = iter.next();
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
-
-    if (iter.hasNext()) {
-      entry = iter.next();
-      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
-    }
-
-    // remove the numeric value constraint
-    getConnector().tableOperations().removeConstraint(tableName, 2);
-    sleepUninterruptibly(1, TimeUnit.SECONDS);
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    // now should be able to add a non numeric value
-    bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
-    bw.addMutation(mut2);
-    bw.close();
+      if (iter.hasNext()) {
+        entry = iter.next();
+        throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    // verify mutation went through
-    iter = scanner.iterator();
-    entry = iter.next();
+      // remove the numeric value constraint
+      getConnector().tableOperations().removeConstraint(tableName, 2);
+      sleepUninterruptibly(1, TimeUnit.SECONDS);
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
+      // now should be able to add a non numeric value
+      bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
+      bw.addMutation(mut2);
+      bw.close();
 
-    if (iter.hasNext()) {
+      // verify mutation went through
+      iter = scanner.iterator();
       entry = iter.next();
-      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
-    }
 
-    // add a constraint that references a non-existant class
-    getConnector().tableOperations().setProperty(tableName, Property.TABLE_CONSTRAINT_PREFIX + "1", "com.foobar.nonExistantClass");
-    sleepUninterruptibly(1, TimeUnit.SECONDS);
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    // add a mutation
-    bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
+      if (iter.hasNext()) {
+        entry = iter.next();
+        throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    Mutation mut3 = new Mutation(new Text("r1"));
-    mut3.put(new Text("cf1"), new Text("cq1"), new Value("foo".getBytes(UTF_8)));
+      // add a constraint that references a non-existant class
+      getConnector().tableOperations().setProperty(tableName, Property.TABLE_CONSTRAINT_PREFIX + "1", "com.foobar.nonExistantClass");
+      sleepUninterruptibly(1, TimeUnit.SECONDS);
 
-    bw.addMutation(mut3);
+      // add a mutation
+      bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
 
-    sawMRE = false;
+      Mutation mut3 = new Mutation(new Text("r1"));
+      mut3.put(new Text("cf1"), new Text("cq1"), new Value("foo".getBytes(UTF_8)));
 
-    try {
-      bw.close();
-      // should not get here
-      throw new Exception("Test failed, mutation went through when table had bad constraints");
-    } catch (MutationsRejectedException mre) {
-      sawMRE = true;
-    }
+      bw.addMutation(mut3);
 
-    if (!sawMRE) {
-      throw new Exception("Did not see MutationsRejectedException");
-    }
+      sawMRE = false;
 
-    // verify the mutation did not go through
-    iter = scanner.iterator();
-    entry = iter.next();
+      try {
+        bw.close();
+        // should not get here
+        throw new Exception("Test failed, mutation went through when table had bad constraints");
+      } catch (MutationsRejectedException mre) {
+        sawMRE = true;
+      }
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
+      if (!sawMRE) {
+        throw new Exception("Did not see MutationsRejectedException");
+      }
 
-    if (iter.hasNext()) {
+      // verify the mutation did not go through
+      iter = scanner.iterator();
       entry = iter.next();
-      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
-    }
 
-    // remove the bad constraint
-    getConnector().tableOperations().removeConstraint(tableName, 1);
-    sleepUninterruptibly(1, TimeUnit.SECONDS);
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    // try the mutation again
-    bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
-    bw.addMutation(mut3);
-    bw.close();
+      if (iter.hasNext()) {
+        entry = iter.next();
+        throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    // verify it went through
-    iter = scanner.iterator();
-    entry = iter.next();
+      // remove the bad constraint
+      getConnector().tableOperations().removeConstraint(tableName, 1);
+      sleepUninterruptibly(1, TimeUnit.SECONDS);
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("foo".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
+      // try the mutation again
+      bw = getConnector().createBatchWriter(tableName, new BatchWriterConfig());
+      bw.addMutation(mut3);
+      bw.close();
 
-    if (iter.hasNext()) {
+      // verify it went through
+      iter = scanner.iterator();
       entry = iter.next();
-      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("foo".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
+
+      if (iter.hasNext()) {
+        entry = iter.next();
+        throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      }
     }
   }
 
@@ -308,29 +305,27 @@ private void test2(String table, boolean doFlush) throws Exception {
       throw new Exception("Did not see MutationsRejectedException");
     }
 
-    Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY);
+    try (Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY)) {
 
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
 
-    Entry<Key,Value> entry = iter.next();
+      Entry<Key,Value> entry = iter.next();
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    entry = iter.next();
+      entry = iter.next();
 
-    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
-        || !entry.getKey().getColumnQualifier().equals(new Text("cq4")) || !entry.getValue().equals(new Value("789".getBytes(UTF_8)))) {
-      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
-    }
+      if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1")) || !entry.getKey().getColumnQualifier().equals(new Text("cq4")) || !entry.getValue().equals(new Value("789".getBytes(UTF_8)))) {
+        throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
+      }
 
-    if (iter.hasNext()) {
-      entry = iter.next();
-      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      if (iter.hasNext()) {
+        entry = iter.next();
+        throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
+      }
     }
-
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
index 919ab30c89..01b3400bc8 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
@@ -77,18 +77,18 @@ public void verifyDataIsPresent() throws Exception {
     }
 
     bw.close();
-    Scanner scanner1 = getConnector().createScanner(tableName, Authorizations.EMPTY);
+    try (Scanner scanner1 = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
 
-    int ei = 1;
+      int ei = 1;
 
-    for (Entry<Key,Value> entry : scanner1) {
-      Assert.assertEquals(String.format("%08x", (ei << 8) - 16), entry.getKey().getRow().toString());
-      Assert.assertEquals(Integer.toString(ei), entry.getValue().toString());
+      for (Entry<Key,Value> entry : scanner1) {
+        Assert.assertEquals(String.format("%08x", (ei << 8) - 16), entry.getKey().getRow().toString());
+        Assert.assertEquals(Integer.toString(ei), entry.getValue().toString());
 
-      ei++;
+        ei++;
+      }
+      Assert.assertEquals("Did not see expected number of rows", 257, ei);
     }
-
-    Assert.assertEquals("Did not see expected number of rows", 257, ei);
   }
 
   @Test
@@ -96,15 +96,16 @@ public void createTableAndScan() throws Exception {
     String table2 = getUniqueNames(1)[0];
     getConnector().tableOperations().create(table2);
     getConnector().tableOperations().addSplits(table2, splits);
-    Scanner scanner2 = getConnector().createScanner(table2, Authorizations.EMPTY);
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner2) {
-      if (entry != null)
-        count++;
-    }
-
-    if (count != 0) {
-      throw new Exception("Did not see expected number of entries, count = " + count);
+    try (Scanner scanner2 = getConnector().createScanner(table2, Authorizations.EMPTY)) {
+      int count = 0;
+      for (Entry<Key,Value> entry : scanner2) {
+        if (entry != null)
+          count++;
+      }
+
+      if (count != 0) {
+        throw new Exception("Did not see expected number of entries, count = " + count);
+      }
     }
   }
 
@@ -118,13 +119,13 @@ public void createTableAndBatchScan() throws Exception {
     String table3 = getUniqueNames(1)[0];
     getConnector().tableOperations().create(table3);
     getConnector().tableOperations().addSplits(table3, splits);
-    BatchScanner bs = getConnector().createBatchScanner(table3, Authorizations.EMPTY, 3);
-    bs.setRanges(ranges);
-    Iterator<Entry<Key,Value>> iter = bs.iterator();
-    int count = Iterators.size(iter);
-    bs.close();
+    try (BatchScanner bs = getConnector().createBatchScanner(table3, Authorizations.EMPTY, 3)) {
+      bs.setRanges(ranges);
+      Iterator<Entry<Key,Value>> iter = bs.iterator();
+      int count = Iterators.size(iter);
 
-    Assert.assertEquals("Did not expect to find any entries", 0, count);
+      Assert.assertEquals("Did not expect to find any entries", 0, count);
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CredentialsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CredentialsIT.java
index b383d0a866..59e78f6421 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CredentialsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CredentialsIT.java
@@ -105,19 +105,20 @@ public void testConnectorWithDestroyedToken() throws Exception {
   public void testDestroyTokenBeforeRPC() throws Exception {
     AuthenticationToken token = getUser(0).getToken();
     Connector userConnector = inst.getConnector(username, token);
-    Scanner scanner = userConnector.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    assertFalse(token.isDestroyed());
-    token.destroy();
-    assertTrue(token.isDestroyed());
-    try {
-      Iterator<Entry<Key,Value>> iter = scanner.iterator();
-      while (iter.hasNext())
+    try (Scanner scanner = userConnector.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      assertFalse(token.isDestroyed());
+      token.destroy();
+      assertTrue(token.isDestroyed());
+      try {
+        Iterator<Entry<Key,Value>> iter = scanner.iterator();
+        while (iter.hasNext())
+          fail();
         fail();
-      fail();
-    } catch (Exception e) {
-      assertTrue(e instanceof RuntimeException);
-      assertTrue(e.getCause() instanceof AccumuloSecurityException);
-      assertTrue(AccumuloSecurityException.class.cast(e.getCause()).getSecurityErrorCode().equals(SecurityErrorCode.TOKEN_EXPIRED));
+      } catch (Exception e) {
+        assertTrue(e instanceof RuntimeException);
+        assertTrue(e.getCause() instanceof AccumuloSecurityException);
+        assertTrue(AccumuloSecurityException.class.cast(e.getCause()).getSecurityErrorCode().equals(SecurityErrorCode.TOKEN_EXPIRED));
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java b/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
index 7b21ca3c24..5416bf2840 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
@@ -97,22 +97,24 @@ public void run() throws Exception {
     bw.addMutation(m);
     bw.flush();
 
-    Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY);
-    scanner.setRange(new Range());
-    int count = Iterators.size(scanner.iterator());
-    assertEquals("count == " + count, 0, count);
-    getConnector().tableOperations().flush(tableName, null, null, true);
+    try (Scanner scanner = getConnector().createScanner(tableName, Authorizations.EMPTY)) {
+      scanner.setRange(new Range());
+      int count = Iterators.size(scanner.iterator());
+      assertEquals("count == " + count, 0, count);
+      getConnector().tableOperations().flush(tableName, null, null, true);
 
-    getConnector().tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "1.0");
-    sleepUninterruptibly(4, TimeUnit.SECONDS);
+      getConnector().tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "1.0");
+      sleepUninterruptibly(4, TimeUnit.SECONDS);
 
-    FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
+      FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
 
-    bw.close();
+      bw.close();
 
-    count = Iterables.size(scanner);
+      count = Iterables.size(scanner);
 
-    if (count != 0)
-      throw new Exception("count == " + count);
+      if (count != 0) {
+        throw new Exception("count == " + count);
+      }
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsIT.java
index 0c0b2361a2..c371290a41 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsIT.java
@@ -74,8 +74,9 @@ public void testDeleteAllRows() throws Exception {
     for (String tableName : tableNames) {
       c.tableOperations().create(tableName);
       c.tableOperations().deleteRows(tableName, null, null);
-      Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY);
-      assertEquals(0, Iterators.size(scanner.iterator()));
+      try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
+        assertEquals(0, Iterators.size(scanner.iterator()));
+      }
     }
   }
 
@@ -139,16 +140,17 @@ private void testSplit(String table, String start, String end, String result, in
       sb.append(split.toString());
     assertEquals(result, sb.toString());
     // See that the rows are really deleted
-    Scanner scanner = c.createScanner(table, Authorizations.EMPTY);
-    int count = 0;
-    for (Entry<Key,Value> entry : scanner) {
-      Text row = entry.getKey().getRow();
-      assertTrue((startText == null || row.compareTo(startText) <= 0) || (endText == null || row.compareTo(endText) > 0));
-      assertTrue(startText != null || endText != null);
-      count++;
+    try (Scanner scanner = c.createScanner(table, Authorizations.EMPTY)) {
+      int count = 0;
+      for (Entry<Key,Value> entry : scanner) {
+        Text row = entry.getKey().getRow();
+        assertTrue((startText == null || row.compareTo(startText) <= 0) || (endText == null || row.compareTo(endText) > 0));
+        assertTrue(startText != null || endText != null);
+        count++;
+      }
+      log.info("Finished table {}", table);
+      assertEquals(entries, count);
     }
-    log.info("Finished table {}", table);
-    assertEquals(entries, count);
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java
index 107c4c51cf..6f07cf7224 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/DeleteRowsSplitIT.java
@@ -112,14 +112,15 @@ public void run() {
       }
 
       // scan the table
-      Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY);
-      for (Entry<Key,Value> entry : scanner) {
-        Text row = entry.getKey().getRow();
-        assertTrue(row.compareTo(start) <= 0 || row.compareTo(end) > 0);
-      }
+      try (Scanner scanner = conn.createScanner(tableName, Authorizations.EMPTY)) {
+        for (Entry<Key,Value> entry : scanner) {
+          Text row = entry.getKey().getRow();
+          assertTrue(row.compareTo(start) <= 0 || row.compareTo(end) > 0);
+        }
 
-      // delete the table
-      conn.tableOperations().delete(tableName);
+        // delete the table
+        conn.tableOperations().delete(tableName);
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java b/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
index 07161d47a2..34922423b1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/FunctionalTestUtils.java
@@ -67,45 +67,46 @@
 public class FunctionalTestUtils {
 
   public static int countRFiles(Connector c, String tableName) throws Exception {
-    Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    Table.ID tableId = Table.ID.of(c.tableOperations().tableIdMap().get(tableName));
-    scanner.setRange(MetadataSchema.TabletsSection.getRange(tableId));
-    scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-
-    return Iterators.size(scanner.iterator());
+    try (Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      Table.ID tableId = Table.ID.of(c.tableOperations().tableIdMap().get(tableName));
+      scanner.setRange(MetadataSchema.TabletsSection.getRange(tableId));
+      scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      return Iterators.size(scanner.iterator());
+    }
   }
 
   static void checkRFiles(Connector c, String tableName, int minTablets, int maxTablets, int minRFiles, int maxRFiles) throws Exception {
-    Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    String tableId = c.tableOperations().tableIdMap().get(tableName);
-    scanner.setRange(new Range(new Text(tableId + ";"), true, new Text(tableId + "<"), true));
-    scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-    MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
+    try (Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      String tableId = c.tableOperations().tableIdMap().get(tableName);
+      scanner.setRange(new Range(new Text(tableId + ";"), true, new Text(tableId + "<"), true));
+      scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+      MetadataSchema.TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(scanner);
 
-    HashMap<Text,Integer> tabletFileCounts = new HashMap<>();
+      HashMap<Text,Integer> tabletFileCounts = new HashMap<>();
 
-    for (Entry<Key,Value> entry : scanner) {
+      for (Entry<Key,Value> entry : scanner) {
 
-      Text row = entry.getKey().getRow();
+        Text row = entry.getKey().getRow();
 
-      Integer count = tabletFileCounts.get(row);
-      if (count == null)
-        count = 0;
-      if (entry.getKey().getColumnFamily().equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
-        count = count + 1;
-      }
+        Integer count = tabletFileCounts.get(row);
+        if (count == null)
+          count = 0;
+        if (entry.getKey().getColumnFamily().equals(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME)) {
+          count = count + 1;
+        }
 
-      tabletFileCounts.put(row, count);
-    }
+        tabletFileCounts.put(row, count);
+      }
 
-    if (tabletFileCounts.size() < minTablets || tabletFileCounts.size() > maxTablets) {
-      throw new Exception("Did not find expected number of tablets " + tabletFileCounts.size());
-    }
+      if (tabletFileCounts.size() < minTablets || tabletFileCounts.size() > maxTablets) {
+        throw new Exception("Did not find expected number of tablets " + tabletFileCounts.size());
+      }
 
-    Set<Entry<Text,Integer>> es = tabletFileCounts.entrySet();
-    for (Entry<Text,Integer> entry : es) {
-      if (entry.getValue() > maxRFiles || entry.getValue() < minRFiles) {
-        throw new Exception("tablet " + entry.getKey() + " has " + entry.getValue() + " map files");
+      Set<Entry<Text,Integer>> es = tabletFileCounts.entrySet();
+      for (Entry<Text,Integer> entry : es) {
+        if (entry.getValue() > maxRFiles || entry.getValue() < minRFiles) {
+          throw new Exception("tablet " + entry.getKey() + " has " + entry.getValue() + " map files");
+        }
       }
     }
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
index f5316033c2..bd5c8bc33c 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
@@ -180,8 +180,9 @@ public void dontGCRootLog() throws Exception {
     // run recovery
     cluster.start();
     // did it recover?
-    Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    Iterators.size(scanner.iterator());
+    try (Scanner scanner = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      Iterators.size(scanner.iterator());
+    }
   }
 
   private Mutation createDelMutation(String path, String cf, String cq, String val) {
@@ -230,15 +231,16 @@ public void testInvalidDelete() throws Exception {
       gc.destroy();
     }
 
-    Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY);
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    assertTrue(iter.hasNext());
-    Entry<Key,Value> entry = iter.next();
-    Assert.assertEquals("r1", entry.getKey().getRow().toString());
-    Assert.assertEquals("cf1", entry.getKey().getColumnFamily().toString());
-    Assert.assertEquals("cq1", entry.getKey().getColumnQualifier().toString());
-    Assert.assertEquals("v1", entry.getValue().toString());
-    Assert.assertFalse(iter.hasNext());
+    try (Scanner scanner = getConnector().createScanner(table, Authorizations.EMPTY)) {
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      assertTrue(iter.hasNext());
+      Entry<Key,Value> entry = iter.next();
+      Assert.assertEquals("r1", entry.getKey().getRow().toString());
+      Assert.assertEquals("cf1", entry.getKey().getColumnFamily().toString());
+      Assert.assertEquals("cq1", entry.getKey().getColumnQualifier().toString());
+      Assert.assertEquals("v1", entry.getValue().toString());
+      Assert.assertFalse(iter.hasNext());
+    }
   }
 
   @Test
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
index d00e5a0584..4b46f5f8f2 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
@@ -377,14 +377,15 @@ public Void run() throws Exception {
         conn.tableOperations().setProperty(table, Property.TABLE_BLOOM_ENABLED.getKey(), "true");
 
         // Read (and proper authorizations)
-        Scanner s = conn.createScanner(table, new Authorizations(viz));
-        Iterator<Entry<Key,Value>> iter = s.iterator();
-        assertTrue("No results from iterator", iter.hasNext());
-        Entry<Key,Value> entry = iter.next();
-        assertEquals(new Key("a", "b", "c", viz, ts), entry.getKey());
-        assertEquals(new Value("d".getBytes()), entry.getValue());
-        assertFalse("Had more results from iterator", iter.hasNext());
-        return null;
+        try (Scanner s = conn.createScanner(table, new Authorizations(viz))) {
+          Iterator<Entry<Key,Value>> iter = s.iterator();
+          assertTrue("No results from iterator", iter.hasNext());
+          Entry<Key,Value> entry = iter.next();
+          assertEquals(new Key("a", "b", "c", viz, ts), entry.getKey());
+          assertEquals(new Value("d".getBytes()), entry.getValue());
+          assertFalse("Had more results from iterator", iter.hasNext());
+          return null;
+        }
       }
     });
   }
@@ -430,11 +431,11 @@ public AuthenticationToken run() throws Exception {
       public Integer run() throws Exception {
         Connector conn = mac.getConnector(rootUser.getPrincipal(), delegationToken);
 
-        BatchScanner bs = conn.createBatchScanner(tableName, Authorizations.EMPTY, 2);
-        bs.setRanges(Collections.singleton(new Range()));
-        int recordsSeen = Iterables.size(bs);
-        bs.close();
-        return recordsSeen;
+        try (BatchScanner bs = conn.createBatchScanner(tableName, Authorizations.EMPTY, 2)) {
+          bs.setRanges(Collections.singleton(new Range()));
+          int recordsSeen = Iterables.size(bs);
+          return recordsSeen;
+        }
       }
     });
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
index dced6dc193..3becc773b5 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosProxyIT.java
@@ -506,8 +506,7 @@ public Void run() throws Exception {
       public Void run() throws Exception {
         ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig());
         Connector conn = inst.getConnector(proxyPrincipal, new KerberosToken());
-        try {
-          Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
+        try (Scanner s = conn.createScanner(tableName, Authorizations.EMPTY)) {
           s.iterator().hasNext();
           Assert.fail("Expected to see an exception");
         } catch (RuntimeException e) {
@@ -535,8 +534,7 @@ public Void run() throws Exception {
       public Void run() throws Exception {
         ZooKeeperInstance inst = new ZooKeeperInstance(mac.getClientConfig());
         Connector conn = inst.getConnector(userWithoutCredentials2, new KerberosToken(userWithoutCredentials3));
-        try {
-          Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
+        try (Scanner s = conn.createScanner(tableName, Authorizations.EMPTY)) {
           s.iterator().hasNext();
           Assert.fail("Expected to see an exception");
         } catch (RuntimeException e) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
index 4774f69b23..db9ef9d03a 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
@@ -182,10 +182,11 @@ private void createReadWriteDrop(Connector conn) throws TableNotFoundException,
     bw.addMutation(m);
     bw.close();
     conn.tableOperations().compact(table, new CompactionConfig().setFlush(true).setWait(true));
-    Scanner s = conn.createScanner(table, Authorizations.EMPTY);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    assertEquals("Did not find the expected key", 0, new Key("a", "b", "c").compareTo(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
-    assertEquals("d", entry.getValue().toString());
-    conn.tableOperations().delete(table);
+    try (Scanner s = conn.createScanner(table, Authorizations.EMPTY)) {
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      assertEquals("Did not find the expected key", 0, new Key("a", "b", "c").compareTo(entry.getKey(), PartialKey.ROW_COLFAM_COLQUAL));
+      assertEquals("d", entry.getValue().toString());
+      conn.tableOperations().delete(table);
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java b/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java
index 5630f81112..27e6190e6b 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java
@@ -214,7 +214,7 @@ private void verify(Connector c, String table) throws Exception {
       }
 
     }
-
+    scanner.close();
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
index d92cd07fad..72f7a47011 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
@@ -102,8 +102,10 @@ private void runMergeTest(Connector conn, String table, String[] splits, String[
     bw.close();
 
     long time = scanner.iterator().next().getKey().getTimestamp();
-    if (time != expected)
+    if (time != expected) {
       throw new RuntimeException("unexpected time " + time + " " + expected);
+    }
+    scanner.close();
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
index fccf23c074..489637f957 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MapReduceIT.java
@@ -87,6 +87,6 @@ static void runTest(Connector c, MiniAccumuloClusterImpl cluster) throws Accumul
       assertEquals(entry.getValue().toString(), new String(check));
       i++;
     }
-
+    s.close();
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
index 3aaa13c446..003becb7c4 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
@@ -198,7 +198,7 @@ private void runMergeTest(Connector conn, String table, String[] splits, String[
     if (!currentSplits.equals(ess)) {
       throw new Exception("split inconsistency " + table + " " + currentSplits + " != " + ess);
     }
-
+    scanner.close();
   }
 
   @Rule
@@ -217,8 +217,8 @@ public TestTabletIterator(Connector conn, String metadataTableName) throws Excep
 
     @Override
     protected void resetScanner() {
-      try {
-        Scanner ds = conn.createScanner(metadataTableName, Authorizations.EMPTY);
+      try (Scanner ds = conn.createScanner(metadataTableName, Authorizations.EMPTY)) {
+
         Text tablet = new KeyExtent(Table.ID.of("0"), new Text("m"), null).getMetadataEntry();
         ds.setRange(new Range(tablet, true, tablet, true));
 
@@ -229,11 +229,8 @@ protected void resetScanner() {
           Key k = entry.getKey();
           m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), k.getTimestamp());
         }
-
         bw.addMutation(m);
-
         bw.close();
-
       } catch (Exception e) {
         throw new RuntimeException(e);
       }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
index eb4e400ca7..551424fc09 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
@@ -94,6 +94,7 @@ public void testFlushAndCompact() throws Exception {
 
     // compaction of metadata table should change file set in root table
     Assert.assertNotEquals(files2, files3);
+    rootScanner.close();
   }
 
   @Test
@@ -115,6 +116,7 @@ public void mergeMeta() throws Exception {
       sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
     }
     assertEquals(0, c.tableOperations().listSplits(MetadataTable.NAME).size());
+    s.close();
   }
 
   @Test
@@ -131,7 +133,6 @@ public void batchScanTest() throws Exception {
       if (e != null)
         count++;
     }
-    s.close();
     assertTrue(count > 0);
 
     // batch scan root metadata table
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
index f02cd72c72..4b39226bc6 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
@@ -571,7 +571,6 @@ private void createTestTable(Connector c, String testUser, String tableName) thr
   }
 
   private void testMissingTablePermission(Connector test_user_conn, ClusterUser testUser, TablePermission perm, String tableName) throws Exception {
-    Scanner scanner;
     BatchWriter writer;
     Mutation m;
     log.debug("Confirming that the lack of the {} permission properly restricts the user", perm);
@@ -579,13 +578,13 @@ private void testMissingTablePermission(Connector test_user_conn, ClusterUser te
     // test permission prior to granting it
     switch (perm) {
       case READ:
-        try {
-          scanner = test_user_conn.createScanner(tableName, Authorizations.EMPTY);
+        try (Scanner scanner = test_user_conn.createScanner(tableName, Authorizations.EMPTY)) {
           int i = 0;
           for (Entry<Key,Value> entry : scanner)
             i += 1 + entry.getKey().getRowData().length();
-          if (i != 0)
+          if (i != 0) {
             throw new IllegalStateException("Should NOT be able to read from the table");
+          }
         } catch (RuntimeException e) {
           AccumuloSecurityException se = (AccumuloSecurityException) e.getCause();
           if (se.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED)
@@ -670,6 +669,8 @@ private void testGrantedTablePermission(Connector test_user_conn, ClusterUser no
         Iterator<Entry<Key,Value>> iter = scanner.iterator();
         while (iter.hasNext())
           iter.next();
+
+        scanner.close();
         break;
       case WRITE:
         writer = test_user_conn.createBatchWriter(tableName, new BatchWriterConfig());
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
index e961b74002..094d5a2f81 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
@@ -394,6 +394,7 @@ public void localityGroupPerf() throws Exception {
     Iterators.size(scanner.iterator());
     bw.close();
     long diff2 = System.currentTimeMillis() - now;
+    scanner.close();
     assertTrue(diff2 < diff);
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RegexGroupBalanceIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RegexGroupBalanceIT.java
index c77ecccbc1..95d4653dcf 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/RegexGroupBalanceIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/RegexGroupBalanceIT.java
@@ -188,6 +188,7 @@ private boolean checkGroup(Table<String,String,MutableInt> groupLocationCounts,
 
       count.increment();
     }
+    s.close();
     return groupLocationCounts;
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
index 74d76b8ec0..195e6458a4 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
@@ -103,7 +103,7 @@ public void run() throws Exception {
     count = Iterators.size(scanner.iterator());
     assertEquals("count == " + count, 0, count);
     bw.close();
-
+    scanner.close();
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
index c82e302340..632a50be98 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
@@ -242,7 +242,6 @@ public void run() {
         if (!testInProgress.get()) {
           scanner.clearScanIterators();
           scanner.close();
-
           return;
         }
 
@@ -267,9 +266,8 @@ public void run() {
         }
 
       }
-
+      scanner.close();
       log.debug("Scanner ran out of data. (info only, not an error) ");
-
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
index 662cf7524a..db38ffb16c 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
@@ -163,7 +163,7 @@ public void run() throws Exception {
     }
 
     bscanner.close();
-
+    scanner.close();
   }
 
   private void verify(Iterable<Entry<Key,Value>> scanner, int start, int finish) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
index 7ab96c44a1..287595caf1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
@@ -204,6 +204,8 @@ private void scanRange(Connector c, String table, IntKey ik1, boolean inclusive1
     if (!expectedIntKey.createKey().equals(expectedEndIntKey.createKey())) {
       throw new Exception(" " + expectedIntKey.createKey() + " != " + expectedEndIntKey.createKey());
     }
+
+    scanner.close();
   }
 
   private static Text createCF(int cf) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
index ec3fdbaba5..b5b4bc0173 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
@@ -117,7 +117,7 @@ public void run() throws Exception {
     sleepUninterruptibly(9, TimeUnit.SECONDS);
 
     verify(iter, 200, 100000);
-
+    scanner.close();
   }
 
   protected void verify(Iterator<Entry<Key,Value>> iter, int start, int stop) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
index 579881ef26..1374784ba4 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
@@ -227,7 +227,8 @@ public void testOneScannerDoesntInterfereWithAnother() throws Exception {
         Entry<Key,Value> next = iterator2.next();
         assertEquals("Test", next.getValue().toString());
       }
-
+      one.close();
+      two.close();
     } finally {
       // Delete file in tmp
       fs.delete(dstPath, true);
@@ -273,7 +274,7 @@ public void testClearContext() throws Exception {
         Entry<Key,Value> next = iterator.next();
         assertEquals("Test", next.getValue().toString());
       }
-
+      one.close();
     } finally {
       // Delete file in tmp
       fs.delete(dstPath, true);
@@ -295,6 +296,7 @@ private void scanCheck(Connector c, String tableName, IteratorSetting cfg, Strin
       assertEquals(expected, next.getValue().toString());
     }
     assertFalse(iterator.hasNext());
+    bs.close();
   }
 
   private void batchCheck(Connector c, String tableName, IteratorSetting cfg, String context, String expected) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java
index 340a58ee27..6ae23d565e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java
@@ -112,6 +112,7 @@ public void testScannerReadaheadConfiguration() throws Exception {
     sw.stop();
 
     long millisWithNoWait = sw.elapsed(TimeUnit.MILLISECONDS);
+    s.close();
 
     // The "no-wait" time should be much less than the "wait-time"
     Assert.assertTrue("Expected less time to be taken with immediate readahead (" + millisWithNoWait + ") than without immediate readahead (" + millisWithWait
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
index f70fc32962..10662f14d6 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
@@ -74,6 +74,8 @@ public void run() throws Exception {
       }
     } catch (Exception e) {
       caught = true;
+    } finally {
+      scanner.close();
     }
 
     if (!caught)
@@ -122,6 +124,8 @@ public void run() throws Exception {
       }
     } catch (Exception e) {
       caught = true;
+    } finally {
+      scanner.close();
     }
 
     if (!caught)
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
index ca59041ff4..edbbd31b9c 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
@@ -140,7 +140,7 @@ public Boolean call() {
       Iterator<Entry<Key,Value>> iter = scanner2.iterator();
       // call super's verify mechanism
       verify(iter, 0, 1000);
-
+      scanner2.close();
     }
 
     int sessionsFound = 0;
@@ -170,6 +170,7 @@ public Boolean call() {
     for (Future<Boolean> callable : callables) {
       callable.cancel(true);
     }
+    scanner.close();
     service.shutdown();
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
index 8cece0b8a2..9ed6a42347 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
@@ -88,6 +88,7 @@ public void sparceColumnFamily() throws Exception {
         }
       }
     }
+    scanner.close();
   }
 
   private Mutation nm(int row, int cf, int val) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
index 272b8dd1f7..da95a8b692 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SplitIT.java
@@ -161,6 +161,7 @@ public void tabletShouldSplit() throws Exception {
         shortened++;
       count++;
     }
+    s.close();
 
     assertTrue("Shortened should be greater than zero: " + shortened, shortened > 0);
     assertTrue("Count should be cgreater than 10: " + count, count > 10);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TableChangeStateIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TableChangeStateIT.java
index 6c4e735cce..9cc41e06a3 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TableChangeStateIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TableChangeStateIT.java
@@ -424,7 +424,7 @@ public void run() {
         if (count != NUM_ROWS) {
           throw new IllegalStateException(String.format("After compaction, number of rows %1$d does not match expected %2$d", count, NUM_ROWS));
         }
-
+        scanner.close();
       } catch (TableNotFoundException ex) {
         throw new IllegalStateException("test failed, table " + tableName + " does not exist", ex);
       } catch (AccumuloSecurityException ex) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
index 19a09f5824..054ace4116 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TableIT.java
@@ -91,6 +91,7 @@ public void test() throws Exception {
     s.setRange(new KeyExtent(id, null, null).toMetadataRange());
     s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
     assertTrue(Iterators.size(s.iterator()) > 0);
+    s.close();
 
     FileSystem fs = getCluster().getFileSystem();
     assertTrue(fs.listStatus(new Path(rootPath + "/accumulo/tables/" + id)).length > 0);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
index 8d52058a28..cdc5215afe 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
@@ -95,6 +95,7 @@ public void createTableTest(String tableName, boolean readOnly) throws Exception
       assert (elt.getKey().getRow().toString().equals(expected));
       count++;
     }
+    scanner.close();
     assertEquals(N, count);
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
index 8b496d8e10..899b07d47f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
@@ -169,6 +169,7 @@ private int findTabletsNeedingAttention(String table, State state) throws TableN
       if (e != null)
         results++;
     }
+    scanner.close();
     return results;
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java b/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
index 8285461a3f..61d93bad3f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
@@ -263,6 +263,7 @@ private void queryDefaultData(Connector c, String tableName) throws Exception {
     // should return all three records
     scanner = getConnector().createScanner(tableName, new Authorizations("BASE", "DEFLABEL"));
     verifyDefault(scanner, 3);
+    scanner.close();
   }
 
   private void verifyDefault(Scanner scanner, int expectedCount) throws Exception {
@@ -292,6 +293,7 @@ private ByteArraySet nbas(Set<String> auths) {
   private void verify(Connector c, String tableName, ByteArraySet nss, String... expected) throws Exception {
     Scanner scanner = c.createScanner(tableName, new Authorizations(nss));
     verify(scanner.iterator(), expected);
+    scanner.close();
 
     BatchScanner bs = getConnector().createBatchScanner(tableName, new Authorizations(nss), 3);
     bs.setRanges(Collections.singleton(new Range()));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java b/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
index 9d88c705d8..0ebff5eec2 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
@@ -213,6 +213,8 @@ private void writeSomeData(Connector conn, String tableName, int row, int col) t
         logs = new ArrayList<>();
       }
     }
+    root.close();
+    meta.close();
     return result;
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
index a7eaef3424..ac26375b3a 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
@@ -83,6 +83,7 @@ public void test() throws Exception {
     assertFalse(i.hasNext());
     // use the master
     c.tableOperations().delete("test_ingest");
+    s.close();
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java b/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
index 63107e56ac..d8f2903641 100644
--- a/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
@@ -136,11 +136,12 @@ public void unclosedWalsLeaveStatusOpen() throws Exception {
 
     refs.updateReplicationEntries(conn, wals);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    Status status = Status.parseFrom(entry.getValue().get());
-    Assert.assertFalse(status.getClosed());
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      Status status = Status.parseFrom(entry.getValue().get());
+      Assert.assertFalse(status.getClosed());
+    }
   }
 
   @Test
@@ -155,11 +156,12 @@ public void closedWalsUpdateStatus() throws Exception {
 
     refs.updateReplicationEntries(conn, wals);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    Status status = Status.parseFrom(entry.getValue().get());
-    Assert.assertTrue(status.getClosed());
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      Status status = Status.parseFrom(entry.getValue().get());
+      Assert.assertTrue(status.getClosed());
+    }
   }
 
   @Test
@@ -174,10 +176,11 @@ public void partiallyReplicatedReferencedWalsAreNotClosed() throws Exception {
 
     refs.updateReplicationEntries(conn, wals);
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    Status status = Status.parseFrom(entry.getValue().get());
-    Assert.assertFalse(status.getClosed());
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      Status status = Status.parseFrom(entry.getValue().get());
+      Assert.assertFalse(status.getClosed());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
index 049a5da41c..68c2b01223 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
@@ -217,12 +217,13 @@ public void testMR() throws Exception {
     MRTester.main(new String[] {"root", ROOT_PASSWORD, table1, table2, instanceName, getCluster().getZooKeepers()});
     assertNull(e1);
 
-    Scanner scanner = c.createScanner(table2, new Authorizations());
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    assertTrue(iter.hasNext());
-    Entry<Key,Value> entry = iter.next();
-    assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
-    assertFalse(iter.hasNext());
+    try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      assertTrue(iter.hasNext());
+      Entry<Key,Value> entry = iter.next();
+      assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
+      assertFalse(iter.hasNext());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
index 78fc76d4ff..478db1d1a1 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
@@ -165,11 +165,12 @@ public void testMR() throws Exception {
     MRTokenFileTester.main(new String[] {tf.getAbsolutePath(), table1, table2});
     assertNull(e1);
 
-    Scanner scanner = c.createScanner(table2, new Authorizations());
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    assertTrue(iter.hasNext());
-    Entry<Key,Value> entry = iter.next();
-    assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
-    assertFalse(iter.hasNext());
+    try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      assertTrue(iter.hasNext());
+      Entry<Key,Value> entry = iter.next();
+      assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
+      assertFalse(iter.hasNext());
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
index 811f3fe480..ff57722e3d 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
@@ -144,11 +144,12 @@ public void testMR() throws Exception {
     MRTester.main(new String[] {table1, table2});
     assertNull(e1);
 
-    Scanner scanner = c.createScanner(table2, new Authorizations());
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    assertTrue(iter.hasNext());
-    Entry<Key,Value> entry = iter.next();
-    assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
-    assertFalse(iter.hasNext());
+    try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      assertTrue(iter.hasNext());
+      Entry<Key,Value> entry = iter.next();
+      assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
+      assertFalse(iter.hasNext());
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
index 6c3b9efd76..db8d060c2b 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/TokenFileIT.java
@@ -158,11 +158,12 @@ public void testMR() throws Exception {
     MRTokenFileTester.main(new String[] {tf.getAbsolutePath(), table1, table2});
     assertNull(e1);
 
-    Scanner scanner = c.createScanner(table2, new Authorizations());
-    Iterator<Entry<Key,Value>> iter = scanner.iterator();
-    assertTrue(iter.hasNext());
-    Entry<Key,Value> entry = iter.next();
-    assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
-    assertFalse(iter.hasNext());
+    try (Scanner scanner = c.createScanner(table2, new Authorizations())) {
+      Iterator<Entry<Key,Value>> iter = scanner.iterator();
+      assertTrue(iter.hasNext());
+      Entry<Key,Value> entry = iter.next();
+      assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
+      assertFalse(iter.hasNext());
+    }
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
index 794d1b14f1..bc2f33ecbe 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java
@@ -177,21 +177,20 @@ public void run() {
 
   private static ScanStats runScanTest(Connector connector, int numLoop, List<Range> ranges) throws Exception {
     Scanner scanner = null;
+    ScanStats stats = new ScanStats();
 
-    BatchScanner bs = connector.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1);
-    bs.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
-    TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(bs);
-
-    bs.setRanges(ranges);
+    try (BatchScanner bs = connector.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1)) {
+      bs.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
+      TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(bs);
 
-    // System.out.println(ranges);
+      bs.setRanges(ranges);
 
-    ScanStats stats = new ScanStats();
-    for (int i = 0; i < numLoop; i++) {
-      ScanStat ss = scan(bs, ranges, scanner);
-      stats.merge(ss);
+      // System.out.println(ranges);
+      for (int i = 0; i < numLoop; i++) {
+        ScanStat ss = scan(bs, ranges, scanner);
+        stats.merge(ss);
+      }
     }
-
     return stats;
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
index 84c4e77170..8040beb17a 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java
@@ -506,82 +506,82 @@ private static int readFilesUsingIterStack(VolumeManager fs, ServerConfiguration
   private static int scanTablet(Connector conn, String table, Authorizations auths, int batchSize, Text prevEndRow, Text endRow, String[] columns)
       throws Exception {
 
-    Scanner scanner = conn.createScanner(table, auths);
-    scanner.setBatchSize(batchSize);
-    scanner.setRange(new Range(prevEndRow, false, endRow, true));
+    try (Scanner scanner = conn.createScanner(table, auths)) {
+      scanner.setBatchSize(batchSize);
+      scanner.setRange(new Range(prevEndRow, false, endRow, true));
 
-    for (String c : columns) {
-      scanner.fetchColumnFamily(new Text(c));
-    }
+      for (String c : columns) {
+        scanner.fetchColumnFamily(new Text(c));
+      }
 
-    int count = 0;
+      int count = 0;
 
-    for (Entry<Key,Value> entry : scanner) {
-      if (entry != null)
-        count++;
+      for (Entry<Key,Value> entry : scanner) {
+        if (entry != null)
+          count++;
+      }
+      return count;
     }
-
-    return count;
   }
 
   private static void calcTabletStats(Connector conn, String table, Authorizations auths, int batchSize, KeyExtent ke, String[] columns) throws Exception {
 
     // long t1 = System.currentTimeMillis();
 
-    Scanner scanner = conn.createScanner(table, auths);
-    scanner.setBatchSize(batchSize);
-    scanner.setRange(new Range(ke.getPrevEndRow(), false, ke.getEndRow(), true));
+    try (Scanner scanner = conn.createScanner(table, auths)) {
+      scanner.setBatchSize(batchSize);
+      scanner.setRange(new Range(ke.getPrevEndRow(), false, ke.getEndRow(), true));
 
-    for (String c : columns) {
-      scanner.fetchColumnFamily(new Text(c));
-    }
+      for (String c : columns) {
+        scanner.fetchColumnFamily(new Text(c));
+      }
 
-    Stat rowLen = new Stat();
-    Stat cfLen = new Stat();
-    Stat cqLen = new Stat();
-    Stat cvLen = new Stat();
-    Stat valLen = new Stat();
-    Stat colsPerRow = new Stat();
+      Stat rowLen = new Stat();
+      Stat cfLen = new Stat();
+      Stat cqLen = new Stat();
+      Stat cvLen = new Stat();
+      Stat valLen = new Stat();
+      Stat colsPerRow = new Stat();
 
-    Text lastRow = null;
-    int colsPerRowCount = 0;
+      Text lastRow = null;
+      int colsPerRowCount = 0;
 
-    for (Entry<Key,Value> entry : scanner) {
+      for (Entry<Key,Value> entry : scanner) {
 
-      Key key = entry.getKey();
-      Text row = key.getRow();
+        Key key = entry.getKey();
+        Text row = key.getRow();
 
-      if (lastRow == null) {
-        lastRow = row;
-      }
+        if (lastRow == null) {
+          lastRow = row;
+        }
 
-      if (!lastRow.equals(row)) {
-        colsPerRow.addStat(colsPerRowCount);
-        lastRow = row;
-        colsPerRowCount = 0;
-      }
+        if (!lastRow.equals(row)) {
+          colsPerRow.addStat(colsPerRowCount);
+          lastRow = row;
+          colsPerRowCount = 0;
+        }
 
-      colsPerRowCount++;
+        colsPerRowCount++;
 
-      rowLen.addStat(row.getLength());
-      cfLen.addStat(key.getColumnFamilyData().length());
-      cqLen.addStat(key.getColumnQualifierData().length());
-      cvLen.addStat(key.getColumnVisibilityData().length());
-      valLen.addStat(entry.getValue().get().length);
-    }
+        rowLen.addStat(row.getLength());
+        cfLen.addStat(key.getColumnFamilyData().length());
+        cqLen.addStat(key.getColumnQualifierData().length());
+        cvLen.addStat(key.getColumnVisibilityData().length());
+        valLen.addStat(entry.getValue().get().length);
+      }
 
-    synchronized (System.out) {
-      System.out.println("");
-      System.out.println("\tTablet " + ke.getUUID() + " statistics : ");
-      printStat("Row length", rowLen);
-      printStat("Column family length", cfLen);
-      printStat("Column qualifier length", cqLen);
-      printStat("Column visibility length", cvLen);
-      printStat("Value length", valLen);
-      printStat("Columns per row", colsPerRow);
-      System.out.println("");
+      synchronized (System.out) {
+        System.out.println("");
+        System.out.println("\tTablet " + ke.getUUID() + " statistics : ");
+        printStat("Row length", rowLen);
+        printStat("Column family length", cfLen);
+        printStat("Column qualifier length", cqLen);
+        printStat("Column visibility length", cvLen);
+        printStat("Value length", valLen);
+        printStat("Columns per row", colsPerRow);
+        System.out.println("");
+      }
     }
-
   }
 
   private static void printStat(String desc, Stat s) {
diff --git a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
index a337091040..a710f4bc2e 100644
--- a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
+++ b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java
@@ -299,15 +299,16 @@ public static void main(String[] args) throws Exception {
 
     // read the locations for the table
     Range tableRange = new KeyExtent(tableId, null, null).toMetadataRange();
-    MetaDataTableScanner s = new MetaDataTableScanner(context, tableRange);
-    long randomSessionID = opts.port;
-    TServerInstance instance = new TServerInstance(addr, randomSessionID);
     List<Assignment> assignments = new ArrayList<>();
-    while (s.hasNext()) {
-      TabletLocationState next = s.next();
-      assignments.add(new Assignment(next.extent, instance));
+    try (MetaDataTableScanner s = new MetaDataTableScanner(context, tableRange)) {
+      long randomSessionID = opts.port;
+      TServerInstance instance = new TServerInstance(addr, randomSessionID);
+
+      while (s.hasNext()) {
+        TabletLocationState next = s.next();
+        assignments.add(new Assignment(next.extent, instance));
+      }
     }
-    s.close();
     // point them to this server
     MetaDataStateStore store = new MetaDataStateStore(context);
     store.setLocations(assignments);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
index b16419bcf3..bbcde8219f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
@@ -203,6 +203,7 @@ public void dataIsNotOverReplicated() throws Exception {
       }
     }
 
+    Scanner s = null;
     try {
       Connector connMaster1 = master1Cluster.getConnector("root", new PasswordToken(password)), connMaster2 = master2Cluster.getConnector("root",
           new PasswordToken(password));
@@ -284,7 +285,7 @@ public void dataIsNotOverReplicated() throws Exception {
       Thread.sleep(1000);
 
       // Sanity check that the element is there on master1
-      Scanner s = connMaster1.createScanner(master1Table, Authorizations.EMPTY);
+      s = connMaster1.createScanner(master1Table, Authorizations.EMPTY);
       Entry<Key,Value> entry = Iterables.getOnlyElement(s);
       Assert.assertEquals("1", entry.getValue().toString());
 
@@ -324,9 +325,13 @@ public void dataIsNotOverReplicated() throws Exception {
       s = connMaster1.createScanner(master1Table, Authorizations.EMPTY);
       entry = Iterables.getOnlyElement(s);
       Assert.assertEquals("1", entry.getValue().toString());
+      s.close();
     } finally {
       master1Cluster.stop();
       master2Cluster.stop();
+      if (s != null) {
+        s.close();
+      }
     }
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/FinishedWorkUpdaterIT.java b/test/src/main/java/org/apache/accumulo/test/replication/FinishedWorkUpdaterIT.java
index f03570fd29..9f1b194920 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/FinishedWorkUpdaterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/FinishedWorkUpdaterIT.java
@@ -77,17 +77,18 @@ public void recordsWithProgressUpdateBothTables() throws Exception {
 
     updater.run();
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    s.setRange(Range.exact(file));
-    StatusSection.limit(s);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-
-    Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
-    Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target.getSourceTableId().canonicalID());
-
-    // We should only rely on the correct begin attribute being returned
-    Status actual = Status.parseFrom(entry.getValue().get());
-    Assert.assertEquals(stat.getBegin(), actual.getBegin());
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      s.setRange(Range.exact(file));
+      StatusSection.limit(s);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+
+      Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
+      Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target.getSourceTableId().canonicalID());
+
+      // We should only rely on the correct begin attribute being returned
+      Status actual = Status.parseFrom(entry.getValue().get());
+      Assert.assertEquals(stat.getBegin(), actual.getBegin());
+    }
   }
 
   @Test
@@ -117,17 +118,18 @@ public void chooseMinimumBeginOffset() throws Exception {
 
     updater.run();
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    s.setRange(Range.exact(file));
-    StatusSection.limit(s);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      s.setRange(Range.exact(file));
+      StatusSection.limit(s);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
 
-    Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
-    Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target1.getSourceTableId().canonicalID());
+      Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
+      Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target1.getSourceTableId().canonicalID());
 
-    // We should only rely on the correct begin attribute being returned
-    Status actual = Status.parseFrom(entry.getValue().get());
-    Assert.assertEquals(1, actual.getBegin());
+      // We should only rely on the correct begin attribute being returned
+      Status actual = Status.parseFrom(entry.getValue().get());
+      Assert.assertEquals(1, actual.getBegin());
+    }
   }
 
   @Test
@@ -157,17 +159,18 @@ public void chooseMinimumBeginOffsetInfiniteEnd() throws Exception {
 
     updater.run();
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    s.setRange(Range.exact(file));
-    StatusSection.limit(s);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      s.setRange(Range.exact(file));
+      StatusSection.limit(s);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
 
-    Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
-    Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target1.getSourceTableId().canonicalID());
+      Assert.assertEquals(entry.getKey().getColumnFamily(), StatusSection.NAME);
+      Assert.assertEquals(entry.getKey().getColumnQualifier().toString(), target1.getSourceTableId().canonicalID());
 
-    // We should only rely on the correct begin attribute being returned
-    Status actual = Status.parseFrom(entry.getValue().get());
-    Assert.assertEquals(1, actual.getBegin());
+      // We should only rely on the correct begin attribute being returned
+      Status actual = Status.parseFrom(entry.getValue().get());
+      Assert.assertEquals(1, actual.getBegin());
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java b/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
index ef11bdf724..8aaf65b2dd 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
@@ -127,21 +127,21 @@ public void configure(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
 
     Assert.assertNotNull("Could not determine table ID for " + tableName, tableId);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    Range r = MetadataSchema.TabletsSection.getRange(tableId);
-    s.setRange(r);
-    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
-
     Set<String> rfiles = new HashSet<>();
-    for (Entry<Key,Value> entry : s) {
-      log.debug("Reading RFiles: {}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
-      // uri://path/to/wal
-      String cq = entry.getKey().getColumnQualifier().toString();
-      String path = new Path(cq).toString();
-      log.debug("Normalize path to rfile: {}", path);
-      rfiles.add(path);
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      Range r = MetadataSchema.TabletsSection.getRange(tableId);
+      s.setRange(r);
+      s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+
+      for (Entry<Key,Value> entry : s) {
+        log.debug("Reading RFiles: {}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
+        // uri://path/to/wal
+        String cq = entry.getKey().getColumnQualifier().toString();
+        String path = new Path(cq).toString();
+        log.debug("Normalize path to rfile: {}", path);
+        rfiles.add(path);
+      }
     }
-
     return rfiles;
   }
 
@@ -154,20 +154,20 @@ public void configure(MiniAccumuloConfigImpl cfg, Configuration coreSite) {
 
     Assert.assertNotNull("Could not determine table ID for " + tableName, tableId);
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    Range r = MetadataSchema.ReplicationSection.getRange();
-    s.setRange(r);
-    s.fetchColumn(MetadataSchema.ReplicationSection.COLF, new Text(tableId));
-
     Map<String,Status> fileToStatus = new HashMap<>();
-    for (Entry<Key,Value> entry : s) {
-      Text file = new Text();
-      MetadataSchema.ReplicationSection.getFile(entry.getKey(), file);
-      Status status = Status.parseFrom(entry.getValue().get());
-      log.info("Got status for {}: {}", file, ProtobufUtil.toString(status));
-      fileToStatus.put(file.toString(), status);
+    try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      Range r = MetadataSchema.ReplicationSection.getRange();
+      s.setRange(r);
+      s.fetchColumn(MetadataSchema.ReplicationSection.COLF, new Text(tableId));
+
+      for (Entry<Key,Value> entry : s) {
+        Text file = new Text();
+        MetadataSchema.ReplicationSection.getFile(entry.getKey(), file);
+        Status status = Status.parseFrom(entry.getValue().get());
+        log.info("Got status for {}: {}", file, ProtobufUtil.toString(status));
+        fileToStatus.put(file.toString(), status);
+      }
     }
-
     return fileToStatus;
   }
 
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
index 991038395e..f15ddc4bb7 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
@@ -305,6 +305,7 @@ public Boolean call() throws Exception {
 
       Assert.assertFalse("Had more data to read from the master", masterIter.hasNext());
       Assert.assertFalse("Had more data to read from the peer", peerIter.hasNext());
+      master.close();
     } finally {
       peerCluster.stop();
     }
@@ -561,6 +562,7 @@ public void dataWasReplicatedToThePeerWithoutDrain() throws Exception {
     Assert.assertFalse("Had more data to read from the master", masterIter.hasNext());
     Assert.assertFalse("Had more data to read from the peer", peerIter.hasNext());
 
+    master.close();
     peerCluster.stop();
   }
 
@@ -681,6 +683,8 @@ public void dataReplicatedToCorrectTableWithoutDrain() throws Exception {
             fullyReplicated |= true;
           }
         }
+
+        s.close();
       }
 
       Assert.assertNotEquals(0, fullyReplicated);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
index c9d4126ece..b531380c0f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/MultiTserverReplicationIT.java
@@ -79,6 +79,7 @@ public void tserverReplicationServicePortsAreAdvertised() throws Exception {
       }
     }
 
+    s.close();
     // Each tserver should also have equial replicaiton services running internally
     Assert.assertEquals("Expected an equal number of replication servicers and tservers", tserverHost.size(), replicationServices.size());
   }
@@ -111,5 +112,6 @@ public void masterReplicationServicePortsAreAdvertised() throws Exception {
     // Neither should be zero as the port
     Assert.assertNotEquals(0, HostAndPort.fromString(masterAddr).getPort());
     Assert.assertNotEquals(0, HostAndPort.fromString(replCoordAddr).getPort());
+    s.close();
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/RemoveCompleteReplicationRecordsIT.java b/test/src/main/java/org/apache/accumulo/test/replication/RemoveCompleteReplicationRecordsIT.java
index 2a4af6b69e..805459e2cf 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/RemoveCompleteReplicationRecordsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/RemoveCompleteReplicationRecordsIT.java
@@ -105,8 +105,6 @@ public void notYetReplicationRecordsIgnored() throws Exception {
     EasyMock.replay(bw);
 
     rcrr.removeCompleteRecords(conn, bs, bw);
-    bs.close();
-
     Assert.assertEquals(numRecords, Iterables.size(ReplicationTable.getScanner(conn)));
   }
 
@@ -139,8 +137,6 @@ public void partiallyReplicatedRecordsIgnored() throws Exception {
 
     // We don't remove any records, so we can just pass in a fake BW for both
     rcrr.removeCompleteRecords(conn, bs, bw);
-    bs.close();
-
     Assert.assertEquals(numRecords, Iterables.size(ReplicationTable.getScanner(conn)));
   }
 
@@ -191,7 +187,6 @@ public void replicatedClosedWorkRecordsAreNotRemovedWithoutClosedStatusRecords()
     try {
       Assert.assertEquals(0l, rcrr.removeCompleteRecords(conn, bs, replBw));
     } finally {
-      bs.close();
       replBw.close();
     }
   }
@@ -274,7 +269,6 @@ public void replicatedClosedRowsAreRemoved() throws Exception {
     try {
       Assert.assertEquals(4l, rcrr.removeCompleteRecords(conn, bs, replBw));
     } finally {
-      bs.close();
       replBw.close();
     }
 
@@ -334,7 +328,6 @@ public void partiallyReplicatedEntriesPrecludeRowDeletion() throws Exception {
     try {
       Assert.assertEquals(0l, rcrr.removeCompleteRecords(conn, bs, replBw));
     } finally {
-      bs.close();
       replBw.close();
     }
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
index 59343ae15a..a89d64a04f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -142,34 +142,34 @@ public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite)
   private Multimap<String,Table.ID> getLogs(Connector conn) throws Exception {
     // Map of server to tableId
     Multimap<TServerInstance,String> serverToTableID = HashMultimap.create();
-    Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    scanner.setRange(MetadataSchema.TabletsSection.getRange());
-    scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
-    for (Entry<Key,Value> entry : scanner) {
-      TServerInstance key = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier());
-      byte[] tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow());
-      serverToTableID.put(key, new String(tableId, UTF_8));
-    }
-    // Map of logs to tableId
-    Multimap<String,Table.ID> logs = HashMultimap.create();
-    Instance i = conn.getInstance();
-    ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
-    WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
-    for (Entry<TServerInstance,List<UUID>> entry : wals.getAllMarkers().entrySet()) {
-      for (UUID id : entry.getValue()) {
-        Pair<WalState,Path> state = wals.state(entry.getKey(), id);
-        for (String tableId : serverToTableID.get(entry.getKey())) {
-          logs.put(state.getSecond().toString(), Table.ID.of(tableId));
+    try (Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      scanner.setRange(MetadataSchema.TabletsSection.getRange());
+      scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME);
+      for (Entry<Key,Value> entry : scanner) {
+        TServerInstance key = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier());
+        byte[] tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow());
+        serverToTableID.put(key, new String(tableId, UTF_8));
+      }
+      // Map of logs to tableId
+      Multimap<String,Table.ID> logs = HashMultimap.create();
+      Instance i = conn.getInstance();
+      ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");
+      WalStateManager wals = new WalStateManager(conn.getInstance(), zk);
+      for (Entry<TServerInstance,List<UUID>> entry : wals.getAllMarkers().entrySet()) {
+        for (UUID id : entry.getValue()) {
+          Pair<WalState,Path> state = wals.state(entry.getKey(), id);
+          for (String tableId : serverToTableID.get(entry.getKey())) {
+            logs.put(state.getSecond().toString(), Table.ID.of(tableId));
+          }
         }
       }
+      return logs;
     }
-    return logs;
   }
 
   private Multimap<String,Table.ID> getAllLogs(Connector conn) throws Exception {
     Multimap<String,Table.ID> logs = getLogs(conn);
-    try {
-      Scanner scanner = conn.createScanner(ReplicationTable.NAME, Authorizations.EMPTY);
+    try (Scanner scanner = conn.createScanner(ReplicationTable.NAME, Authorizations.EMPTY)) {
       StatusSection.limit(scanner);
       Text buff = new Text();
       for (Entry<Key,Value> entry : scanner) {
@@ -184,6 +184,7 @@ public void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite)
 
         logs.put(file, tableId);
       }
+      scanner.close();
     } catch (TableOfflineException e) {
       log.debug("Replication table isn't online yet");
     }
@@ -320,6 +321,7 @@ public void correctRecordsCompleteFile() throws Exception {
 
         replRows.add(fileUri);
       }
+      scanner.close();
     }
 
     Set<String> wals = new HashSet<>();
@@ -417,63 +419,70 @@ public void twoEntriesForTwoTables() throws Exception {
     Assert.assertTrue(ReplicationTable.isOnline(conn));
 
     // Verify that we found a single replication record that's for table1
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    for (int i = 0; i < 5; i++) {
-      if (Iterators.size(s.iterator()) == 1) {
-        break;
+    Scanner s = null;
+    try {
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      for (int i = 0; i < 5; i++) {
+        if (Iterators.size(s.iterator()) == 1) {
+          break;
+        }
+        Thread.sleep(1000);
       }
-      Thread.sleep(1000);
-    }
-    Entry<Key,Value> entry = Iterators.getOnlyElement(s.iterator());
-    // We should at least find one status record for this table, we might find a second if another log was started from ingesting the data
-    Assert.assertEquals("Expected to find replication entry for " + table1, conn.tableOperations().tableIdMap().get(table1), entry.getKey()
-        .getColumnQualifier().toString());
-    s.close();
+      Entry<Key,Value> entry = Iterators.getOnlyElement(s.iterator());
+      // We should at least find one status record for this table, we might find a second if another log was started from ingesting the data
+      Assert.assertEquals("Expected to find replication entry for " + table1, conn.tableOperations().tableIdMap().get(table1),
+          entry.getKey().getColumnQualifier().toString());
+      s.close();
 
-    // Enable replication on table2
-    conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION.getKey(), "true");
+      // Enable replication on table2
+      conn.tableOperations().setProperty(table2, Property.TABLE_REPLICATION.getKey(), "true");
 
-    // Write some data to table2
-    writeSomeData(conn, table2, 50, 50);
+      // Write some data to table2
+      writeSomeData(conn, table2, 50, 50);
 
-    // After the commit on these mutations, we'll get a replication entry in accumulo.metadata for table2
-    // Don't want to compact table2 as it ultimately cause the entry in accumulo.metadata to be removed before we can verify it's there
+      // After the commit on these mutations, we'll get a replication entry in accumulo.metadata for table2
+      // Don't want to compact table2 as it ultimately cause the entry in accumulo.metadata to be removed before we can verify it's there
 
-    Set<String> tableIds = Sets.newHashSet(conn.tableOperations().tableIdMap().get(table1), conn.tableOperations().tableIdMap().get(table2));
-    Set<String> tableIdsForMetadata = Sets.newHashSet(tableIds);
+      Set<String> tableIds = Sets.newHashSet(conn.tableOperations().tableIdMap().get(table1), conn.tableOperations().tableIdMap().get(table2));
+      Set<String> tableIdsForMetadata = Sets.newHashSet(tableIds);
 
-    List<Entry<Key,Value>> records = new ArrayList<>();
-    s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(MetadataSchema.ReplicationSection.getRange());
-    for (Entry<Key,Value> metadata : s) {
-      records.add(metadata);
-      log.debug("Meta: {} => {}", metadata.getKey().toStringNoTruncate(), metadata.getValue().toString());
-    }
+      List<Entry<Key,Value>> records = new ArrayList<>();
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.setRange(MetadataSchema.ReplicationSection.getRange());
+      for (Entry<Key,Value> metadata : s) {
+        records.add(metadata);
+        log.debug("Meta: {} => {}", metadata.getKey().toStringNoTruncate(), metadata.getValue().toString());
+      }
 
-    Assert.assertEquals("Expected to find 2 records, but actually found " + records, 2, records.size());
+      Assert.assertEquals("Expected to find 2 records, but actually found " + records, 2, records.size());
 
-    for (Entry<Key,Value> metadata : records) {
-      Assert.assertTrue("Expected record to be in metadata but wasn't " + metadata.getKey().toStringNoTruncate() + ", tableIds remaining "
-          + tableIdsForMetadata, tableIdsForMetadata.remove(metadata.getKey().getColumnQualifier().toString()));
-    }
+      for (Entry<Key,Value> metadata : records) {
+        Assert.assertTrue("Expected record to be in metadata but wasn't " + metadata.getKey().toStringNoTruncate() + ", tableIds remaining " + tableIdsForMetadata,
+            tableIdsForMetadata.remove(metadata.getKey().getColumnQualifier().toString()));
+      }
 
-    Assert.assertTrue("Expected that we had removed all metadata entries " + tableIdsForMetadata, tableIdsForMetadata.isEmpty());
+      Assert.assertTrue("Expected that we had removed all metadata entries " + tableIdsForMetadata, tableIdsForMetadata.isEmpty());
 
-    // Should be creating these records in replication table from metadata table every second
-    Thread.sleep(5000);
+      // Should be creating these records in replication table from metadata table every second
+      Thread.sleep(5000);
 
-    // Verify that we found two replication records: one for table1 and one for table2
-    s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Iterator<Entry<Key,Value>> iter = s.iterator();
-    Assert.assertTrue("Found no records in replication table", iter.hasNext());
-    entry = iter.next();
-    Assert.assertTrue("Expected to find element in replication table", tableIds.remove(entry.getKey().getColumnQualifier().toString()));
-    Assert.assertTrue("Expected to find two elements in replication table, only found one ", iter.hasNext());
-    entry = iter.next();
-    Assert.assertTrue("Expected to find element in replication table", tableIds.remove(entry.getKey().getColumnQualifier().toString()));
-    Assert.assertFalse("Expected to only find two elements in replication table", iter.hasNext());
+      // Verify that we found two replication records: one for table1 and one for table2
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      Iterator<Entry<Key,Value>> iter = s.iterator();
+      Assert.assertTrue("Found no records in replication table", iter.hasNext());
+      entry = iter.next();
+      Assert.assertTrue("Expected to find element in replication table", tableIds.remove(entry.getKey().getColumnQualifier().toString()));
+      Assert.assertTrue("Expected to find two elements in replication table, only found one ", iter.hasNext());
+      entry = iter.next();
+      Assert.assertTrue("Expected to find element in replication table", tableIds.remove(entry.getKey().getColumnQualifier().toString()));
+      Assert.assertFalse("Expected to only find two elements in replication table", iter.hasNext());
+    } finally {
+      if (s != null) {
+        s.close();
+      }
+    }
   }
 
   private void writeSomeData(Connector conn, String table, int rows, int cols) throws Exception {
@@ -583,13 +592,14 @@ public void run() {
   }
 
   private Set<String> getReferencesToFilesToBeReplicated(final Connector conn) throws ReplicationTableOfflineException {
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Set<String> replFiles = new HashSet<>();
-    for (Entry<Key,Value> entry : s) {
-      replFiles.add(entry.getKey().getRow().toString());
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      StatusSection.limit(s);
+      Set<String> replFiles = new HashSet<>();
+      for (Entry<Key,Value> entry : s) {
+        replFiles.add(entry.getKey().getRow().toString());
+      }
+      return replFiles;
     }
-    return replFiles;
   }
 
   @Test
@@ -609,25 +619,32 @@ public void combinerWorksOnMetadata() throws Exception {
     bw.addMutation(m);
     bw.close();
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
+    Scanner s = null;
+    try {
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.setRange(ReplicationSection.getRange());
 
-    Status actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get());
-    Assert.assertEquals(stat1, actual);
+      Status actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get());
+      Assert.assertEquals(stat1, actual);
 
-    bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-    m = new Mutation(ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
-    m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat2));
-    bw.addMutation(m);
-    bw.close();
+      bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
+      m = new Mutation(ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
+      m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat2));
+      bw.addMutation(m);
+      bw.close();
 
-    s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.setRange(ReplicationSection.getRange());
 
-    actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get());
-    Status expected = Status.newBuilder().setBegin(0).setEnd(0).setClosed(true).setInfiniteEnd(true).setCreatedTime(100).build();
+      actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get());
+      Status expected = Status.newBuilder().setBegin(0).setEnd(0).setClosed(true).setInfiniteEnd(true).setCreatedTime(100).build();
 
-    Assert.assertEquals(expected, actual);
+      Assert.assertEquals(expected, actual);
+    } finally {
+      if (s != null) {
+        s.close();
+      }
+    }
   }
 
   @Test
@@ -700,83 +717,91 @@ public void filesClosedAfterUnused() throws Exception {
     bw.addMutation(m);
     bw.close();
 
-    Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    s.fetchColumnFamily(TabletsSection.LogColumnFamily.NAME);
-    s.setRange(TabletsSection.getRange(tableId));
-    Set<String> wals = new HashSet<>();
-    for (Entry<Key,Value> entry : s) {
-      LogEntry logEntry = LogEntry.fromKeyValue(entry.getKey(), entry.getValue());
-      wals.add(new Path(logEntry.filename).toString());
-    }
-
-    log.warn("Found wals {}", wals);
+    Scanner s = null;
+    try {
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      s.fetchColumnFamily(TabletsSection.LogColumnFamily.NAME);
+      s.setRange(TabletsSection.getRange(tableId));
+      Set<String> wals = new HashSet<>();
+      for (Entry<Key,Value> entry : s) {
+        LogEntry logEntry = LogEntry.fromKeyValue(entry.getKey(), entry.getValue());
+        wals.add(new Path(logEntry.filename).toString());
+      }
 
-    bw = conn.createBatchWriter(table, new BatchWriterConfig());
-    m = new Mutation("three");
-    byte[] bytes = new byte[1024 * 1024];
-    m.put("1".getBytes(), new byte[0], bytes);
-    m.put("2".getBytes(), new byte[0], bytes);
-    m.put("3".getBytes(), new byte[0], bytes);
-    m.put("4".getBytes(), new byte[0], bytes);
-    m.put("5".getBytes(), new byte[0], bytes);
-    bw.addMutation(m);
-    bw.close();
+      log.warn("Found wals {}", wals);
 
-    conn.tableOperations().flush(table, null, null, true);
+      bw = conn.createBatchWriter(table, new BatchWriterConfig());
+      m = new Mutation("three");
+      byte[] bytes = new byte[1024 * 1024];
+      m.put("1".getBytes(), new byte[0], bytes);
+      m.put("2".getBytes(), new byte[0], bytes);
+      m.put("3".getBytes(), new byte[0], bytes);
+      m.put("4".getBytes(), new byte[0], bytes);
+      m.put("5".getBytes(), new byte[0], bytes);
+      bw.addMutation(m);
+      bw.close();
 
-    while (!ReplicationTable.isOnline(conn)) {
-      sleepUninterruptibly(MILLIS_BETWEEN_REPLICATION_TABLE_ONLINE_CHECKS, TimeUnit.MILLISECONDS);
-    }
+      conn.tableOperations().flush(table, null, null, true);
 
-    for (int i = 0; i < 10; i++) {
-      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-      s.fetchColumnFamily(LogColumnFamily.NAME);
-      s.setRange(TabletsSection.getRange(tableId));
-      for (Entry<Key,Value> entry : s) {
-        log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
+      while (!ReplicationTable.isOnline(conn)) {
+        sleepUninterruptibly(MILLIS_BETWEEN_REPLICATION_TABLE_ONLINE_CHECKS, TimeUnit.MILLISECONDS);
       }
 
-      try {
-        s = ReplicationTable.getScanner(conn);
-        StatusSection.limit(s);
-        Text buff = new Text();
-        boolean allReferencedLogsClosed = true;
-        int recordsFound = 0;
-        for (Entry<Key,Value> e : s) {
-          recordsFound++;
-          allReferencedLogsClosed = true;
-          StatusSection.getFile(e.getKey(), buff);
-          String file = buff.toString();
-          if (wals.contains(file)) {
-            Status stat = Status.parseFrom(e.getValue().get());
-            if (!stat.getClosed()) {
-              log.info("{} wasn't closed", file);
-              allReferencedLogsClosed = false;
+      for (int i = 0; i < 10; i++) {
+        s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+        s.fetchColumnFamily(LogColumnFamily.NAME);
+        s.setRange(TabletsSection.getRange(tableId));
+        for (Entry<Key,Value> entry : s) {
+          log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
+        }
+
+        try {
+          s = ReplicationTable.getScanner(conn);
+          StatusSection.limit(s);
+          Text buff = new Text();
+          boolean allReferencedLogsClosed = true;
+          int recordsFound = 0;
+          for (Entry<Key,Value> e : s) {
+            recordsFound++;
+            allReferencedLogsClosed = true;
+            StatusSection.getFile(e.getKey(), buff);
+            String file = buff.toString();
+            if (wals.contains(file)) {
+              Status stat = Status.parseFrom(e.getValue().get());
+              if (!stat.getClosed()) {
+                log.info("{} wasn't closed", file);
+                allReferencedLogsClosed = false;
+              }
             }
           }
-        }
 
-        if (recordsFound > 0 && allReferencedLogsClosed) {
-          return;
-        }
-        Thread.sleep(2000);
-      } catch (RuntimeException e) {
-        Throwable cause = e.getCause();
-        if (cause instanceof AccumuloSecurityException) {
-          AccumuloSecurityException ase = (AccumuloSecurityException) cause;
-          switch (ase.getSecurityErrorCode()) {
-            case PERMISSION_DENIED:
-              // We tried to read the replication table before the GRANT went through
-              Thread.sleep(2000);
-              break;
-            default:
-              throw e;
+          if (recordsFound > 0 && allReferencedLogsClosed) {
+            return;
+          }
+          Thread.sleep(2000);
+        } catch (RuntimeException e) {
+          Throwable cause = e.getCause();
+          if (cause instanceof AccumuloSecurityException) {
+            AccumuloSecurityException ase = (AccumuloSecurityException) cause;
+            switch (ase.getSecurityErrorCode()) {
+              case PERMISSION_DENIED:
+                // We tried to read the replication table before the GRANT went through
+                Thread.sleep(2000);
+                break;
+              default:
+                throw e;
+            }
           }
         }
       }
-    }
 
-    Assert.fail("We had a file that was referenced but didn't get closed");
+      s.close();
+      Assert.fail("We had a file that was referenced but didn't get closed");
+    } finally {
+      if (s != null) {
+        s.close();
+      }
+    }
   }
 
   @Test
@@ -838,107 +863,114 @@ public void singleTableWithSingleTarget() throws Exception {
     conn.tableOperations().flush(table1, null, null, true);
 
     // Make sure that we have one status element, should be a new file
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Entry<Key,Value> entry = null;
-    Status expectedStatus = StatusUtil.openWithUnknownLength();
-    attempts = 10;
-    // This record will move from new to new with infinite length because of the minc (flush)
-    while (null == entry && attempts > 0) {
-      try {
-        entry = Iterables.getOnlyElement(s);
-        Status actual = Status.parseFrom(entry.getValue().get());
-        if (actual.getInfiniteEnd() != expectedStatus.getInfiniteEnd()) {
+    Scanner s = null;
+    try {
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      Entry<Key,Value> entry = null;
+      Status expectedStatus = StatusUtil.openWithUnknownLength();
+      attempts = 10;
+      // This record will move from new to new with infinite length because of the minc (flush)
+      while (null == entry && attempts > 0) {
+        try {
+          entry = Iterables.getOnlyElement(s);
+          Status actual = Status.parseFrom(entry.getValue().get());
+          if (actual.getInfiniteEnd() != expectedStatus.getInfiniteEnd()) {
+            entry = null;
+            // the master process didn't yet fire and write the new mutation, wait for it to do
+            // so and try to read it again
+            Thread.sleep(1000);
+          }
+        } catch (NoSuchElementException e) {
           entry = null;
-          // the master process didn't yet fire and write the new mutation, wait for it to do
-          // so and try to read it again
-          Thread.sleep(1000);
+          Thread.sleep(500);
+        } catch (IllegalArgumentException e) {
+          // saw this contain 2 elements once
+          s = ReplicationTable.getScanner(conn);
+          StatusSection.limit(s);
+          for (Entry<Key,Value> content : s) {
+            log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+          }
+          throw e;
+        } finally {
+          attempts--;
+        }
+      }
+
+      Assert.assertNotNull("Could not find expected entry in replication table", entry);
+      Status actual = Status.parseFrom(entry.getValue().get());
+      Assert.assertTrue("Expected to find a replication entry that is open with infinite length: " + ProtobufUtil.toString(actual), !actual.getClosed() && actual.getInfiniteEnd());
+
+      // Try a couple of times to watch for the work record to be created
+      boolean notFound = true;
+      for (int i = 0; i < 10 && notFound; i++) {
+        s = ReplicationTable.getScanner(conn);
+        WorkSection.limit(s);
+        int elementsFound = Iterables.size(s);
+        if (0 < elementsFound) {
+          Assert.assertEquals(1, elementsFound);
+          notFound = false;
         }
-      } catch (NoSuchElementException e) {
-        entry = null;
         Thread.sleep(500);
-      } catch (IllegalArgumentException e) {
-        // saw this contain 2 elements once
+      }
+
+      // If we didn't find the work record, print the contents of the table
+      if (notFound) {
         s = ReplicationTable.getScanner(conn);
-        StatusSection.limit(s);
         for (Entry<Key,Value> content : s) {
           log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
         }
-        throw e;
-      } finally {
-        attempts--;
+        Assert.assertFalse("Did not find the work entry for the status entry", notFound);
       }
-    }
 
-    Assert.assertNotNull("Could not find expected entry in replication table", entry);
-    Status actual = Status.parseFrom(entry.getValue().get());
-    Assert.assertTrue("Expected to find a replication entry that is open with infinite length: " + ProtobufUtil.toString(actual),
-        !actual.getClosed() && actual.getInfiniteEnd());
+      // Write some more data so that we over-run the single WAL
+      writeSomeData(conn, table1, 3000, 50);
 
-    // Try a couple of times to watch for the work record to be created
-    boolean notFound = true;
-    for (int i = 0; i < 10 && notFound; i++) {
-      s = ReplicationTable.getScanner(conn);
-      WorkSection.limit(s);
-      int elementsFound = Iterables.size(s);
-      if (0 < elementsFound) {
-        Assert.assertEquals(1, elementsFound);
-        notFound = false;
-      }
-      Thread.sleep(500);
-    }
+      log.info("Issued compaction for table");
+      conn.tableOperations().compact(table1, null, null, true, true);
+      log.info("Compaction completed");
+
+      // Master is creating entries in the replication table from the metadata table every second.
+      // Compaction should trigger the record to be written to metadata. Wait a bit to ensure
+      // that the master has time to work.
+      Thread.sleep(5000);
 
-    // If we didn't find the work record, print the contents of the table
-    if (notFound) {
       s = ReplicationTable.getScanner(conn);
-      for (Entry<Key,Value> content : s) {
-        log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+      StatusSection.limit(s);
+      int numRecords = 0;
+      for (Entry<Key,Value> e : s) {
+        numRecords++;
+        log.info("Found status record {}\t{}", e.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(e.getValue().get())));
       }
-      Assert.assertFalse("Did not find the work entry for the status entry", notFound);
-    }
-
-    // Write some more data so that we over-run the single WAL
-    writeSomeData(conn, table1, 3000, 50);
 
-    log.info("Issued compaction for table");
-    conn.tableOperations().compact(table1, null, null, true, true);
-    log.info("Compaction completed");
-
-    // Master is creating entries in the replication table from the metadata table every second.
-    // Compaction should trigger the record to be written to metadata. Wait a bit to ensure
-    // that the master has time to work.
-    Thread.sleep(5000);
+      Assert.assertEquals(2, numRecords);
 
-    s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    int numRecords = 0;
-    for (Entry<Key,Value> e : s) {
-      numRecords++;
-      log.info("Found status record {}\t{}", e.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(e.getValue().get())));
-    }
-
-    Assert.assertEquals(2, numRecords);
-
-    // We should eventually get 2 work records recorded, need to account for a potential delay though
-    // might see: status1 -> work1 -> status2 -> (our scans) -> work2
-    notFound = true;
-    for (int i = 0; i < 10 && notFound; i++) {
-      s = ReplicationTable.getScanner(conn);
-      WorkSection.limit(s);
-      int elementsFound = Iterables.size(s);
-      if (2 == elementsFound) {
-        notFound = false;
+      // We should eventually get 2 work records recorded, need to account for a potential delay though
+      // might see: status1 -> work1 -> status2 -> (our scans) -> work2
+      notFound = true;
+      for (int i = 0; i < 10 && notFound; i++) {
+        s = ReplicationTable.getScanner(conn);
+        WorkSection.limit(s);
+        int elementsFound = Iterables.size(s);
+        if (2 == elementsFound) {
+          notFound = false;
+        }
+        Thread.sleep(500);
       }
-      Thread.sleep(500);
-    }
 
-    // If we didn't find the work record, print the contents of the table
-    if (notFound) {
-      s = ReplicationTable.getScanner(conn);
-      for (Entry<Key,Value> content : s) {
-        log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+      // If we didn't find the work record, print the contents of the table
+      if (notFound) {
+        s = ReplicationTable.getScanner(conn);
+        for (Entry<Key,Value> content : s) {
+          log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+        }
+        Assert.assertFalse("Did not find the work entries for the status entries", notFound);
+      }
+      s.close();
+    } finally {
+      if (s != null) {
+        s.close();
       }
-      Assert.assertFalse("Did not find the work entries for the status entries", notFound);
     }
   }
 
@@ -990,32 +1022,40 @@ public void correctClusterNameInWorkEntry() throws Exception {
     Assert.assertTrue(conn.securityOperations().hasTablePermission("root", ReplicationTable.NAME, TablePermission.READ));
 
     boolean notFound = true;
-    Scanner s;
-    for (int i = 0; i < 10 && notFound; i++) {
-      s = ReplicationTable.getScanner(conn);
-      WorkSection.limit(s);
-      try {
-        Entry<Key,Value> e = Iterables.getOnlyElement(s);
-        Text expectedColqual = new ReplicationTarget("cluster1", "4", tableId).toText();
-        Assert.assertEquals(expectedColqual, e.getKey().getColumnQualifier());
-        notFound = false;
-      } catch (NoSuchElementException e) {} catch (IllegalArgumentException e) {
+    Scanner s = null;
+    try {
+      for (int i = 0; i < 10 && notFound; i++) {
+        s = ReplicationTable.getScanner(conn);
+        WorkSection.limit(s);
+        try {
+          Entry<Key,Value> e = Iterables.getOnlyElement(s);
+          Text expectedColqual = new ReplicationTarget("cluster1", "4", tableId).toText();
+          Assert.assertEquals(expectedColqual, e.getKey().getColumnQualifier());
+          notFound = false;
+        } catch (NoSuchElementException e) {
+        } catch (IllegalArgumentException e) {
+          s = ReplicationTable.getScanner(conn);
+          for (Entry<Key,Value> content : s) {
+            log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+          }
+          Assert.fail("Found more than one work section entry");
+        }
+
+        s.close();
+        Thread.sleep(500);
+      }
+
+      if (notFound) {
         s = ReplicationTable.getScanner(conn);
         for (Entry<Key,Value> content : s) {
           log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
         }
-        Assert.fail("Found more than one work section entry");
+        Assert.assertFalse("Did not find the work entry for the status entry", notFound);
       }
-
-      Thread.sleep(500);
-    }
-
-    if (notFound) {
-      s = ReplicationTable.getScanner(conn);
-      for (Entry<Key,Value> content : s) {
-        log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+    } finally {
+      if (s != null) {
+        s.close();
       }
-      Assert.assertFalse("Did not find the work entry for the status entry", notFound);
     }
   }
 
@@ -1110,72 +1150,74 @@ public void run() {
       // We should either find all closed records or no records
       // After they're closed, they are candidates for deletion
       for (int i = 0; i < 10; i++) {
-        Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-        s.setRange(Range.prefix(ReplicationSection.getRowPrefix()));
-        Iterator<Entry<Key,Value>> iter = s.iterator();
-
-        long recordsFound = 0l;
-        while (allClosed && iter.hasNext()) {
-          Entry<Key,Value> entry = iter.next();
-          String wal = entry.getKey().getRow().toString();
-          if (metadataWals.contains(wal)) {
-            Status status = Status.parseFrom(entry.getValue().get());
-            log.info("{}={}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(status));
-            allClosed &= status.getClosed();
-            recordsFound++;
+        try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+          s.setRange(Range.prefix(ReplicationSection.getRowPrefix()));
+          Iterator<Entry<Key,Value>> iter = s.iterator();
+
+          long recordsFound = 0l;
+          while (allClosed && iter.hasNext()) {
+            Entry<Key,Value> entry = iter.next();
+            String wal = entry.getKey().getRow().toString();
+            if (metadataWals.contains(wal)) {
+              Status status = Status.parseFrom(entry.getValue().get());
+              log.info("{}={}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(status));
+              allClosed &= status.getClosed();
+              recordsFound++;
+            }
           }
-        }
 
-        log.info("Found {} records from the metadata table", recordsFound);
-        if (allClosed) {
-          break;
+          log.info("Found {} records from the metadata table", recordsFound);
+          if (allClosed) {
+            break;
+          }
+          sleepUninterruptibly(2, TimeUnit.SECONDS);
         }
-
-        sleepUninterruptibly(2, TimeUnit.SECONDS);
       }
 
       if (!allClosed) {
-        Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-        s.setRange(Range.prefix(ReplicationSection.getRowPrefix()));
-        for (Entry<Key,Value> entry : s) {
-          log.info("{} {}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(entry.getValue().get())));
+        try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+          s.setRange(Range.prefix(ReplicationSection.getRowPrefix()));
+          for (Entry<Key,Value> entry : s) {
+            log.info("{} {}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(entry.getValue().get())));
+          }
+          Assert.fail("Expected all replication records in the metadata table to be closed");
         }
-        Assert.fail("Expected all replication records in the metadata table to be closed");
       }
 
       for (int i = 0; i < 10; i++) {
         allClosed = true;
 
-        Scanner s = ReplicationTable.getScanner(conn);
-        Iterator<Entry<Key,Value>> iter = s.iterator();
-
-        long recordsFound = 0l;
-        while (allClosed && iter.hasNext()) {
-          Entry<Key,Value> entry = iter.next();
-          String wal = entry.getKey().getRow().toString();
-          if (metadataWals.contains(wal)) {
-            Status status = Status.parseFrom(entry.getValue().get());
-            log.info("{}={}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(status));
-            allClosed &= status.getClosed();
-            recordsFound++;
+        try (Scanner s = ReplicationTable.getScanner(conn)) {
+          Iterator<Entry<Key,Value>> iter = s.iterator();
+
+          long recordsFound = 0l;
+          while (allClosed && iter.hasNext()) {
+            Entry<Key,Value> entry = iter.next();
+            String wal = entry.getKey().getRow().toString();
+            if (metadataWals.contains(wal)) {
+              Status status = Status.parseFrom(entry.getValue().get());
+              log.info("{}={}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(status));
+              allClosed &= status.getClosed();
+              recordsFound++;
+            }
           }
-        }
 
-        log.info("Found {} records from the replication table", recordsFound);
-        if (allClosed) {
-          break;
+          log.info("Found {} records from the replication table", recordsFound);
+          if (allClosed) {
+            break;
+          }
+          sleepUninterruptibly(3, TimeUnit.SECONDS);
         }
-
-        sleepUninterruptibly(3, TimeUnit.SECONDS);
       }
 
       if (!allClosed) {
-        Scanner s = ReplicationTable.getScanner(conn);
-        StatusSection.limit(s);
-        for (Entry<Key,Value> entry : s) {
-          log.info("{} {}", entry.getKey().toStringNoTruncate(), TextFormat.shortDebugString(Status.parseFrom(entry.getValue().get())));
+        try (Scanner s = ReplicationTable.getScanner(conn)) {
+          StatusSection.limit(s);
+          for (Entry<Key,Value> entry : s) {
+            log.info("{} {}", entry.getKey().toStringNoTruncate(), TextFormat.shortDebugString(Status.parseFrom(entry.getValue().get())));
+          }
+          Assert.fail("Expected all replication records in the replication table to be closed");
         }
-        Assert.fail("Expected all replication records in the replication table to be closed");
       }
 
     } finally {
@@ -1238,161 +1280,166 @@ public void replicatedStatusEntriesAreDeleted() throws Exception {
 
     log.info("Checking for replication entries in replication");
     // Then we need to get those records over to the replication table
-    Scanner s;
-    Set<String> entries = new HashSet<>();
-    for (int i = 0; i < 5; i++) {
-      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-      s.setRange(ReplicationSection.getRange());
-      entries.clear();
-      for (Entry<Key,Value> entry : s) {
-        entries.add(entry.getKey().getRow().toString());
-        log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
-      }
-      if (!entries.isEmpty()) {
-        log.info("Replication entries {}", entries);
-        break;
+    Scanner s = null;
+    try {
+      Set<String> entries = new HashSet<>();
+      for (int i = 0; i < 5; i++) {
+        s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+        s.setRange(ReplicationSection.getRange());
+        entries.clear();
+        for (Entry<Key,Value> entry : s) {
+          entries.add(entry.getKey().getRow().toString());
+          log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
+        }
+        if (!entries.isEmpty()) {
+          log.info("Replication entries {}", entries);
+          break;
+        }
+        Thread.sleep(1000);
       }
-      Thread.sleep(1000);
-    }
 
-    Assert.assertFalse("Did not find any replication entries in the replication table", entries.isEmpty());
+      Assert.assertFalse("Did not find any replication entries in the replication table", entries.isEmpty());
 
-    // Find the WorkSection record that will be created for that data we ingested
-    boolean notFound = true;
-    for (int i = 0; i < 10 && notFound; i++) {
-      try {
-        s = ReplicationTable.getScanner(conn);
-        WorkSection.limit(s);
-        Entry<Key,Value> e = Iterables.getOnlyElement(s);
-        log.info("Found entry: {}", e.getKey().toStringNoTruncate());
-        Text expectedColqual = new ReplicationTarget("cluster1", "4", tableId).toText();
-        Assert.assertEquals(expectedColqual, e.getKey().getColumnQualifier());
-        notFound = false;
-      } catch (NoSuchElementException e) {
-
-      } catch (IllegalArgumentException e) {
-        // Somehow we got more than one element. Log what they were
-        s = ReplicationTable.getScanner(conn);
-        for (Entry<Key,Value> content : s) {
-          log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
-        }
-        Assert.fail("Found more than one work section entry");
-      } catch (RuntimeException e) {
-        // Catch a propagation issue, fail if it's not what we expect
-        Throwable cause = e.getCause();
-        if (cause instanceof AccumuloSecurityException) {
-          AccumuloSecurityException sec = (AccumuloSecurityException) cause;
-          switch (sec.getSecurityErrorCode()) {
-            case PERMISSION_DENIED:
-              // retry -- the grant didn't happen yet
-              log.warn("Sleeping because permission was denied");
-              break;
-            default:
-              throw e;
+      // Find the WorkSection record that will be created for that data we ingested
+      boolean notFound = true;
+      for (int i = 0; i < 10 && notFound; i++) {
+        try {
+          s = ReplicationTable.getScanner(conn);
+          WorkSection.limit(s);
+          Entry<Key,Value> e = Iterables.getOnlyElement(s);
+          log.info("Found entry: {}", e.getKey().toStringNoTruncate());
+          Text expectedColqual = new ReplicationTarget("cluster1", "4", tableId).toText();
+          Assert.assertEquals(expectedColqual, e.getKey().getColumnQualifier());
+          notFound = false;
+        } catch (NoSuchElementException e) {
+
+        } catch (IllegalArgumentException e) {
+          // Somehow we got more than one element. Log what they were
+          s = ReplicationTable.getScanner(conn);
+          for (Entry<Key,Value> content : s) {
+            log.info("{} => {}", content.getKey().toStringNoTruncate(), content.getValue());
+          }
+          Assert.fail("Found more than one work section entry");
+        } catch (RuntimeException e) {
+          // Catch a propagation issue, fail if it's not what we expect
+          Throwable cause = e.getCause();
+          if (cause instanceof AccumuloSecurityException) {
+            AccumuloSecurityException sec = (AccumuloSecurityException) cause;
+            switch (sec.getSecurityErrorCode()) {
+              case PERMISSION_DENIED:
+                // retry -- the grant didn't happen yet
+                log.warn("Sleeping because permission was denied");
+                break;
+              default:
+                throw e;
+            }
+          } else {
+            throw e;
           }
-        } else {
-          throw e;
         }
-      }
-
-      Thread.sleep(2000);
-    }
 
-    if (notFound) {
-      s = ReplicationTable.getScanner(conn);
-      for (Entry<Key,Value> content : s) {
-        log.info("{} => {}", content.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(content.getValue().get())));
+        Thread.sleep(2000);
       }
-      Assert.assertFalse("Did not find the work entry for the status entry", notFound);
-    }
 
-    /**
-     * By this point, we should have data ingested into a table, with at least one WAL as a candidate for replication. Compacting the table should close all
-     * open WALs, which should ensure all records we're going to replicate have entries in the replication table, and nothing will exist in the metadata table
-     * anymore
-     */
+      if (notFound) {
+        s = ReplicationTable.getScanner(conn);
+        for (Entry<Key,Value> content : s) {
+          log.info("{} => {}", content.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(content.getValue().get())));
+        }
+        Assert.assertFalse("Did not find the work entry for the status entry", notFound);
+      }
 
-    log.info("Killing tserver");
-    // Kill the tserver(s) and restart them
-    // to ensure that the WALs we previously observed all move to closed.
-    cluster.getClusterControl().stop(ServerType.TABLET_SERVER);
+      /**
+       * By this point, we should have data ingested into a table, with at least one WAL as a candidate for replication. Compacting the table should close all
+       * open WALs, which should ensure all records we're going to replicate have entries in the replication table, and nothing will exist in the metadata table
+       * anymore
+       */
 
-    log.info("Starting tserver");
-    cluster.getClusterControl().start(ServerType.TABLET_SERVER);
+      log.info("Killing tserver");
+      // Kill the tserver(s) and restart them
+      // to ensure that the WALs we previously observed all move to closed.
+      cluster.getClusterControl().stop(ServerType.TABLET_SERVER);
 
-    log.info("Waiting to read tables");
-    sleepUninterruptibly(2 * 3, TimeUnit.SECONDS);
+      log.info("Starting tserver");
+      cluster.getClusterControl().start(ServerType.TABLET_SERVER);
 
-    // Make sure we can read all the tables (recovery complete)
-    for (String table : new String[] {MetadataTable.NAME, table1}) {
-      Iterators.size(conn.createScanner(table, Authorizations.EMPTY).iterator());
-    }
+      log.info("Waiting to read tables");
+      sleepUninterruptibly(2 * 3, TimeUnit.SECONDS);
 
-    log.info("Recovered metadata:");
-    s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    for (Entry<Key,Value> entry : s) {
-      log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
-    }
+      // Make sure we can read all the tables (recovery complete)
+      for (String table : new String[] {MetadataTable.NAME, table1}) {
+        Iterators.size(conn.createScanner(table, Authorizations.EMPTY).iterator());
+      }
 
-    cluster.getClusterControl().start(ServerType.GARBAGE_COLLECTOR);
+      log.info("Recovered metadata:");
+      s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+      for (Entry<Key,Value> entry : s) {
+        log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
+      }
 
-    // Wait for a bit since the GC has to run (should be running after a one second delay)
-    waitForGCLock(conn);
+      cluster.getClusterControl().start(ServerType.GARBAGE_COLLECTOR);
 
-    Thread.sleep(1000);
+      // Wait for a bit since the GC has to run (should be running after a one second delay)
+      waitForGCLock(conn);
 
-    log.info("After GC");
-    s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-    for (Entry<Key,Value> entry : s) {
-      log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
-    }
+      Thread.sleep(1000);
 
-    // We expect no records in the metadata table after compaction. We have to poll
-    // because we have to wait for the StatusMaker's next iteration which will clean
-    // up the dangling *closed* records after we create the record in the replication table.
-    // We need the GC to close the file (CloseWriteAheadLogReferences) before we can remove the record
-    log.info("Checking metadata table for replication entries");
-    Set<String> remaining = new HashSet<>();
-    for (int i = 0; i < 10; i++) {
+      log.info("After GC");
       s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
-      s.setRange(ReplicationSection.getRange());
-      remaining.clear();
-      for (Entry<Key,Value> e : s) {
-        remaining.add(e.getKey().getRow().toString());
+      for (Entry<Key,Value> entry : s) {
+        log.info("{}={}", entry.getKey().toStringNoTruncate(), entry.getValue());
       }
-      remaining.retainAll(entries);
-      if (remaining.isEmpty()) {
-        break;
+
+      // We expect no records in the metadata table after compaction. We have to poll
+      // because we have to wait for the StatusMaker's next iteration which will clean
+      // up the dangling *closed* records after we create the record in the replication table.
+      // We need the GC to close the file (CloseWriteAheadLogReferences) before we can remove the record
+      log.info("Checking metadata table for replication entries");
+      Set<String> remaining = new HashSet<>();
+      for (int i = 0; i < 10; i++) {
+        s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
+        s.setRange(ReplicationSection.getRange());
+        remaining.clear();
+        for (Entry<Key,Value> e : s) {
+          remaining.add(e.getKey().getRow().toString());
+        }
+        remaining.retainAll(entries);
+        if (remaining.isEmpty()) {
+          break;
+        }
+        log.info("remaining {}", remaining);
+        Thread.sleep(2000);
+        log.info("");
       }
-      log.info("remaining {}", remaining);
-      Thread.sleep(2000);
-      log.info("");
-    }
 
-    Assert.assertTrue("Replication status messages were not cleaned up from metadata table", remaining.isEmpty());
+      Assert.assertTrue("Replication status messages were not cleaned up from metadata table", remaining.isEmpty());
 
-    /**
-     * After we close out and subsequently delete the metadata record, this will propagate to the replication table, which will cause those records to be
-     * deleted after replication occurs
-     */
+      /**
+       * After we close out and subsequently delete the metadata record, this will propagate to the replication table, which will cause those records to be
+       * deleted after replication occurs
+       */
 
-    int recordsFound = 0;
-    for (int i = 0; i < 30; i++) {
-      s = ReplicationTable.getScanner(conn);
-      recordsFound = 0;
-      for (Entry<Key,Value> entry : s) {
-        recordsFound++;
-        log.info("{} {}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(entry.getValue().get())));
-      }
+      int recordsFound = 0;
+      for (int i = 0; i < 30; i++) {
+        s = ReplicationTable.getScanner(conn);
+        recordsFound = 0;
+        for (Entry<Key,Value> entry : s) {
+          recordsFound++;
+          log.info("{} {}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(Status.parseFrom(entry.getValue().get())));
+        }
 
-      if (recordsFound <= 2) {
-        break;
-      } else {
-        Thread.sleep(1000);
-        log.info("");
+        if (recordsFound <= 2) {
+          break;
+        } else {
+          Thread.sleep(1000);
+          log.info("");
+        }
+      }
+      Assert.assertTrue("Found unexpected replication records in the replication table", recordsFound <= 2);
+    } finally {
+      if (s != null) {
+        s.close();
       }
     }
-
-    Assert.assertTrue("Found unexpected replication records in the replication table", recordsFound <= 2);
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/StatusCombinerMacIT.java b/test/src/main/java/org/apache/accumulo/test/replication/StatusCombinerMacIT.java
index 8b8dceb7eb..df7e2a5063 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/StatusCombinerMacIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/StatusCombinerMacIT.java
@@ -108,23 +108,31 @@ public void test() throws Exception {
       bw.close();
     }
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    Entry<Key,Value> entry = Iterables.getOnlyElement(s);
-    Assert.assertEquals(StatusUtil.fileCreatedValue(createTime), entry.getValue());
-
-    bw = ReplicationTable.getBatchWriter(conn);
+    Scanner s = null;
     try {
-      Mutation m = new Mutation("file:/accumulo/wal/HW10447.local+56808/93cdc17e-7521-44fa-87b5-37f45bcb92d3");
-      StatusSection.add(m, Table.ID.of("1"), ProtobufUtil.toValue(StatusUtil.replicated(Long.MAX_VALUE)));
-      bw.addMutation(m);
+      s = ReplicationTable.getScanner(conn);
+      Entry<Key,Value> entry = Iterables.getOnlyElement(s);
+      Assert.assertEquals(StatusUtil.fileCreatedValue(createTime), entry.getValue());
+
+      bw = ReplicationTable.getBatchWriter(conn);
+      try {
+        Mutation m = new Mutation("file:/accumulo/wal/HW10447.local+56808/93cdc17e-7521-44fa-87b5-37f45bcb92d3");
+        StatusSection.add(m, Table.ID.of("1"), ProtobufUtil.toValue(StatusUtil.replicated(Long.MAX_VALUE)));
+        bw.addMutation(m);
+      } finally {
+        bw.close();
+      }
+
+      s = ReplicationTable.getScanner(conn);
+      entry = Iterables.getOnlyElement(s);
+      Status stat = Status.parseFrom(entry.getValue().get());
+      Assert.assertEquals(Long.MAX_VALUE, stat.getBegin());
+      s.close();
     } finally {
-      bw.close();
+      if (s != null) {
+        s.close();
+      }
     }
-
-    s = ReplicationTable.getScanner(conn);
-    entry = Iterables.getOnlyElement(s);
-    Status stat = Status.parseFrom(entry.getValue().get());
-    Assert.assertEquals(Long.MAX_VALUE, stat.getBegin());
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/StatusMakerIT.java b/test/src/main/java/org/apache/accumulo/test/replication/StatusMakerIT.java
index ad8d3a9059..5eaf5e96a2 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/StatusMakerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/StatusMakerIT.java
@@ -97,18 +97,19 @@ public void statusRecordsCreated() throws Exception {
 
     statusMaker.run();
 
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Text file = new Text();
-    for (Entry<Key,Value> entry : s) {
-      StatusSection.getFile(entry.getKey(), file);
-      Table.ID tableId = StatusSection.getTableId(entry.getKey());
-
-      Assert.assertTrue("Found unexpected file: " + file, files.contains(file.toString()));
-      Assert.assertEquals(fileToTableId.get(file.toString()), new Integer(tableId.canonicalID()));
-      timeCreated = fileToTimeCreated.get(file.toString());
-      Assert.assertNotNull(timeCreated);
-      Assert.assertEquals(StatusUtil.fileCreated(timeCreated), Status.parseFrom(entry.getValue().get()));
+    try (Scanner s = ReplicationTable.getScanner(conn)) {
+      StatusSection.limit(s);
+      Text file = new Text();
+      for (Entry<Key,Value> entry : s) {
+        StatusSection.getFile(entry.getKey(), file);
+        Table.ID tableId = StatusSection.getTableId(entry.getKey());
+
+        Assert.assertTrue("Found unexpected file: " + file, files.contains(file.toString()));
+        Assert.assertEquals(fileToTableId.get(file.toString()), new Integer(tableId.canonicalID()));
+        timeCreated = fileToTimeCreated.get(file.toString());
+        Assert.assertNotNull(timeCreated);
+        Assert.assertEquals(StatusUtil.fileCreated(timeCreated), Status.parseFrom(entry.getValue().get()));
+      }
     }
   }
 
@@ -142,10 +143,11 @@ public void openMessagesAreNotDeleted() throws Exception {
 
     statusMaker.run();
 
-    Scanner s = conn.createScanner(sourceTable, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    Assert.assertEquals(files.size(), Iterables.size(s));
+    try (Scanner s = conn.createScanner(sourceTable, Authorizations.EMPTY)) {
+      s.setRange(ReplicationSection.getRange());
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      Assert.assertEquals(files.size(), Iterables.size(s));
+    }
   }
 
   @Test
@@ -178,17 +180,23 @@ public void closedMessagesAreDeleted() throws Exception {
 
     statusMaker.run();
 
-    Scanner s = conn.createScanner(sourceTable, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    for (Entry<Key,Value> e : s) {
-      System.out.println(e.getKey().toStringNoTruncate() + " " + e.getValue());
+    Scanner s = null;
+    try {
+      s = conn.createScanner(sourceTable, Authorizations.EMPTY);
+      s.setRange(ReplicationSection.getRange());
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      for (Entry<Key,Value> e : s) {
+        System.out.println(e.getKey().toStringNoTruncate() + " " + e.getValue());
+      }
+      s = conn.createScanner(sourceTable, Authorizations.EMPTY);
+      s.setRange(ReplicationSection.getRange());
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      Assert.assertEquals(0, Iterables.size(s));
+    } finally {
+      if (s != null) {
+        s.close();
+      }
     }
-    s = conn.createScanner(sourceTable, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    Assert.assertEquals(0, Iterables.size(s));
-
   }
 
   @Test
@@ -223,27 +231,35 @@ public void closedMessagesCreateOrderRecords() throws Exception {
 
     statusMaker.run();
 
-    Scanner s = conn.createScanner(sourceTable, Authorizations.EMPTY);
-    s.setRange(ReplicationSection.getRange());
-    s.fetchColumnFamily(ReplicationSection.COLF);
-    Assert.assertEquals(0, Iterables.size(s));
-
-    s = ReplicationTable.getScanner(conn);
-    OrderSection.limit(s);
-    Iterator<Entry<Key,Value>> iter = s.iterator();
-    Assert.assertTrue("Found no order records in replication table", iter.hasNext());
-
-    Iterator<String> expectedFiles = files.iterator();
-    Text buff = new Text();
-    while (expectedFiles.hasNext() && iter.hasNext()) {
-      String file = expectedFiles.next();
-      Entry<Key,Value> entry = iter.next();
-
-      Assert.assertEquals(file, OrderSection.getFile(entry.getKey(), buff));
-      OrderSection.getTableId(entry.getKey(), buff);
-      Assert.assertEquals(fileToTableId.get(file).intValue(), Integer.parseInt(buff.toString()));
+    Scanner s = null;
+    Iterator<Entry<Key,Value>> iter;
+    Iterator<String> expectedFiles;
+    try {
+      s = conn.createScanner(sourceTable, Authorizations.EMPTY);
+      s.setRange(ReplicationSection.getRange());
+      s.fetchColumnFamily(ReplicationSection.COLF);
+      Assert.assertEquals(0, Iterables.size(s));
+
+      s = ReplicationTable.getScanner(conn);
+      OrderSection.limit(s);
+      iter = s.iterator();
+      Assert.assertTrue("Found no order records in replication table", iter.hasNext());
+
+      expectedFiles = files.iterator();
+      Text buff = new Text();
+      while (expectedFiles.hasNext() && iter.hasNext()) {
+        String file = expectedFiles.next();
+        Entry<Key,Value> entry = iter.next();
+
+        Assert.assertEquals(file, OrderSection.getFile(entry.getKey(), buff));
+        OrderSection.getTableId(entry.getKey(), buff);
+        Assert.assertEquals(fileToTableId.get(file).intValue(), Integer.parseInt(buff.toString()));
+      }
+    } finally {
+      if (s != null) {
+        s.close();
+      }
     }
-
     Assert.assertFalse("Found more files unexpectedly", expectedFiles.hasNext());
     Assert.assertFalse("Found more entries in replication table unexpectedly", iter.hasNext());
   }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
index 3ee9f936fd..10aa0531ca 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
@@ -302,6 +302,7 @@ public Boolean call() throws Exception {
 
       Assert.assertFalse("Had more data to read from the master", masterIter.hasNext());
       Assert.assertFalse("Had more data to read from the peer", peerIter.hasNext());
+      master.close();
     } finally {
       peerCluster.stop();
     }
@@ -566,6 +567,7 @@ public void dataWasReplicatedToThePeerWithoutDrain() throws Exception {
     Assert.assertFalse("Had more data to read from the master", masterIter.hasNext());
     Assert.assertFalse("Had more data to read from the peer", peerIter.hasNext());
 
+    master.close();
     peerCluster.stop();
   }
 
@@ -678,12 +680,13 @@ public void dataReplicatedToCorrectTableWithoutDrain() throws Exception {
       for (int i = 0; i < 10 && !fullyReplicated; i++) {
         sleepUninterruptibly(timeoutFactor * 2, TimeUnit.SECONDS);
 
-        Scanner s = ReplicationTable.getScanner(connMaster);
-        WorkSection.limit(s);
-        for (Entry<Key,Value> entry : s) {
-          Status status = Status.parseFrom(entry.getValue().get());
-          if (StatusUtil.isFullyReplicated(status)) {
-            fullyReplicated |= true;
+        try (Scanner s = ReplicationTable.getScanner(connMaster)) {
+          WorkSection.limit(s);
+          for (Entry<Key,Value> entry : s) {
+            Status status = Status.parseFrom(entry.getValue().get());
+            if (StatusUtil.isFullyReplicated(status)) {
+              fullyReplicated |= true;
+            }
           }
         }
       }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java b/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
index 63961bd600..3bbc42d109 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
@@ -216,5 +216,6 @@ public void test() throws Exception {
       log.info("{} {}", entry.getKey().toStringNoTruncate(), ProtobufUtil.toString(status));
       Assert.assertFalse("Status record was closed and it should not be", status.getClosed());
     }
+    s.close();
   }
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/WorkMakerIT.java b/test/src/main/java/org/apache/accumulo/test/replication/WorkMakerIT.java
index da9ebb2e67..bcd655da70 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/WorkMakerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/WorkMakerIT.java
@@ -98,29 +98,37 @@ public void singleUnitSingleTarget() throws Exception {
     bw.flush();
 
     // Assert that we have one record in the status section
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Assert.assertEquals(1, Iterables.size(s));
-
-    MockWorkMaker workMaker = new MockWorkMaker(conn);
-
-    // Invoke the addWorkRecord method to create a Work record from the Status record earlier
-    ReplicationTarget expected = new ReplicationTarget("remote_cluster_1", "4", tableId);
-    workMaker.setBatchWriter(bw);
-    workMaker.addWorkRecord(new Text(file), StatusUtil.fileCreatedValue(timeCreated), ImmutableMap.of("remote_cluster_1", "4"), tableId);
-
-    // Scan over just the WorkSection
-    s = ReplicationTable.getScanner(conn);
-    WorkSection.limit(s);
-
-    Entry<Key,Value> workEntry = Iterables.getOnlyElement(s);
-    Key workKey = workEntry.getKey();
-    ReplicationTarget actual = ReplicationTarget.from(workKey.getColumnQualifier());
-
-    Assert.assertEquals(file, workKey.getRow().toString());
-    Assert.assertEquals(WorkSection.NAME, workKey.getColumnFamily());
-    Assert.assertEquals(expected, actual);
-    Assert.assertEquals(workEntry.getValue(), StatusUtil.fileCreatedValue(timeCreated));
+    Scanner s = null;
+    try {
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      Assert.assertEquals(1, Iterables.size(s));
+
+      MockWorkMaker workMaker = new MockWorkMaker(conn);
+
+      // Invoke the addWorkRecord method to create a Work record from the Status record earlier
+      ReplicationTarget expected = new ReplicationTarget("remote_cluster_1", "4", tableId);
+      workMaker.setBatchWriter(bw);
+      workMaker.addWorkRecord(new Text(file), StatusUtil.fileCreatedValue(timeCreated), ImmutableMap.of("remote_cluster_1", "4"), tableId);
+
+      // Scan over just the WorkSection
+      s = ReplicationTable.getScanner(conn);
+      WorkSection.limit(s);
+
+      Entry<Key,Value> workEntry = Iterables.getOnlyElement(s);
+      Key workKey = workEntry.getKey();
+      ReplicationTarget actual = ReplicationTarget.from(workKey.getColumnQualifier());
+
+      Assert.assertEquals(file, workKey.getRow().toString());
+      Assert.assertEquals(WorkSection.NAME, workKey.getColumnFamily());
+      Assert.assertEquals(expected, actual);
+      Assert.assertEquals(workEntry.getValue(), StatusUtil.fileCreatedValue(timeCreated));
+      s.close();
+    } finally {
+      if (s != null) {
+        s.close();
+      }
+    }
   }
 
   @Test
@@ -139,38 +147,45 @@ public void singleUnitMultipleTargets() throws Exception {
     bw.flush();
 
     // Assert that we have one record in the status section
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Assert.assertEquals(1, Iterables.size(s));
-
-    MockWorkMaker workMaker = new MockWorkMaker(conn);
-
-    Map<String,String> targetClusters = ImmutableMap.of("remote_cluster_1", "4", "remote_cluster_2", "6", "remote_cluster_3", "8");
-    Set<ReplicationTarget> expectedTargets = new HashSet<>();
-    for (Entry<String,String> cluster : targetClusters.entrySet()) {
-      expectedTargets.add(new ReplicationTarget(cluster.getKey(), cluster.getValue(), tableId));
+    Scanner s = null;
+    try {
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      Assert.assertEquals(1, Iterables.size(s));
+
+      MockWorkMaker workMaker = new MockWorkMaker(conn);
+
+      Map<String,String> targetClusters = ImmutableMap.of("remote_cluster_1", "4", "remote_cluster_2", "6", "remote_cluster_3", "8");
+      Set<ReplicationTarget> expectedTargets = new HashSet<>();
+      for (Entry<String,String> cluster : targetClusters.entrySet()) {
+        expectedTargets.add(new ReplicationTarget(cluster.getKey(), cluster.getValue(), tableId));
+      }
+      workMaker.setBatchWriter(bw);
+      workMaker.addWorkRecord(new Text(file), StatusUtil.fileCreatedValue(System.currentTimeMillis()), targetClusters, tableId);
+
+      s = ReplicationTable.getScanner(conn);
+      WorkSection.limit(s);
+
+      Set<ReplicationTarget> actualTargets = new HashSet<>();
+      for (Entry<Key,Value> entry : s) {
+        Assert.assertEquals(file, entry.getKey().getRow().toString());
+        Assert.assertEquals(WorkSection.NAME, entry.getKey().getColumnFamily());
+
+        ReplicationTarget target = ReplicationTarget.from(entry.getKey().getColumnQualifier());
+        actualTargets.add(target);
+      }
+
+      for (ReplicationTarget expected : expectedTargets) {
+        Assert.assertTrue("Did not find expected target: " + expected, actualTargets.contains(expected));
+        actualTargets.remove(expected);
+      }
+
+      Assert.assertTrue("Found extra replication work entries: " + actualTargets, actualTargets.isEmpty());
+    } finally {
+      if (s != null) {
+        s.close();
+      }
     }
-    workMaker.setBatchWriter(bw);
-    workMaker.addWorkRecord(new Text(file), StatusUtil.fileCreatedValue(System.currentTimeMillis()), targetClusters, tableId);
-
-    s = ReplicationTable.getScanner(conn);
-    WorkSection.limit(s);
-
-    Set<ReplicationTarget> actualTargets = new HashSet<>();
-    for (Entry<Key,Value> entry : s) {
-      Assert.assertEquals(file, entry.getKey().getRow().toString());
-      Assert.assertEquals(WorkSection.NAME, entry.getKey().getColumnFamily());
-
-      ReplicationTarget target = ReplicationTarget.from(entry.getKey().getColumnQualifier());
-      actualTargets.add(target);
-    }
-
-    for (ReplicationTarget expected : expectedTargets) {
-      Assert.assertTrue("Did not find expected target: " + expected, actualTargets.contains(expected));
-      actualTargets.remove(expected);
-    }
-
-    Assert.assertTrue("Found extra replication work entries: " + actualTargets, actualTargets.isEmpty());
   }
 
   @Test
@@ -187,24 +202,27 @@ public void dontCreateWorkForEntriesWithNothingToReplicate() throws Exception {
     bw.flush();
 
     // Assert that we have one record in the status section
-    Scanner s = ReplicationTable.getScanner(conn);
-    StatusSection.limit(s);
-    Assert.assertEquals(1, Iterables.size(s));
+    Scanner s = null;
+    try {
+      s = ReplicationTable.getScanner(conn);
+      StatusSection.limit(s);
+      Assert.assertEquals(1, Iterables.size(s));
 
-    MockWorkMaker workMaker = new MockWorkMaker(conn);
+      MockWorkMaker workMaker = new MockWorkMaker(conn);
 
-    conn.tableOperations().setProperty(ReplicationTable.NAME, Property.TABLE_REPLICATION_TARGET.getKey() + "remote_cluster_1", "4");
+      conn.tableOperations().setProperty(ReplicationTable.NAME, Property.TABLE_REPLICATION_TARGET.getKey() + "remote_cluster_1", "4");
 
-    workMaker.setBatchWriter(bw);
+      workMaker.setBatchWriter(bw);
 
-    // If we don't shortcircuit out, we should get an exception because ServerConfiguration.getTableConfiguration
-    // won't work with MockAccumulo
-    workMaker.run();
+      // If we don't shortcircuit out, we should get an exception because ServerConfiguration.getTableConfiguration
+      // won't work with MockAccumulo
+      workMaker.run();
 
-    s = ReplicationTable.getScanner(conn);
-    WorkSection.limit(s);
+      s = ReplicationTable.getScanner(conn);
+      WorkSection.limit(s);
 
-    Assert.assertEquals(0, Iterables.size(s));
+      Assert.assertEquals(0, Iterables.size(s));
+    }
   }
 
 }
diff --git a/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java b/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
index 20f73906ec..ae1564a0b9 100644
--- a/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/server/security/SystemCredentialsIT.java
@@ -191,8 +191,7 @@ public Connector getConnector(String user, byte[] pass) throws AccumuloException
       System.exit(BAD_PASSWD_FAIL_CODE);
       return;
     }
-    try {
-      Scanner scan = conn.createScanner(RootTable.NAME, Authorizations.EMPTY);
+    try (Scanner scan = conn.createScanner(RootTable.NAME, Authorizations.EMPTY)) {
       for (Entry<Key,Value> e : scan) {
         e.hashCode();
       }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services