accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch master updated: Fix warnings about unclosed resources
Date Wed, 18 Mar 2020 22:09:04 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new afa0bf4  Fix warnings about unclosed resources
afa0bf4 is described below

commit afa0bf40818d334a326c9077f6084f53f805e3eb
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Wed Mar 18 18:08:31 2020 -0400

    Fix warnings about unclosed resources
---
 .../org/apache/accumulo/core/conf/ConfigurationDocGen.java   |  4 +++-
 .../master/tableOps/tableImport/ImportPopulateZookeeper.java |  3 ++-
 .../test/replication/RemoveCompleteReplicationRecordsIT.java |  8 +++++---
 .../test/replication/ReplicationOperationsImplIT.java        | 12 ++++++++----
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
index da8c587..acc4434 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
@@ -155,7 +155,9 @@ class ConfigurationDocGen {
    */
   public static void main(String[] args) throws IOException {
     if (args.length == 2 && args[0].equals("--generate-markdown")) {
-      new ConfigurationDocGen(new PrintStream(args[1], UTF_8)).generate();
+      try (var printStream = new PrintStream(args[1], UTF_8)) {
+        new ConfigurationDocGen(printStream).generate();
+      }
     } else {
       throw new IllegalArgumentException(
           "Usage: " + ConfigurationDocGen.class.getName() + " --generate-markdown <filename>");
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java
b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java
index ad6767f..885f0e8 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java
@@ -90,7 +90,8 @@ class ImportPopulateZookeeper extends MasterRepo {
       Utils.getTableNameLock().unlock();
     }
 
-    for (Entry<String,String> entry : getExportedProps(env.getVolumeManager()).entrySet())
+    VolumeManager volMan = env.getVolumeManager();
+    for (Entry<String,String> entry : getExportedProps(volMan).entrySet())
       if (!TablePropUtil.setTableProperty(env.getContext(), tableInfo.tableId, entry.getKey(),
           entry.getValue())) {
         throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonical(),
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 4c8966d..906e8f5 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
@@ -295,9 +295,11 @@ public class RemoveCompleteReplicationRecordsIT extends ConfigurableMacBase
{
       }
 
       int actualRecords = 0;
-      for (Entry<Key,Value> entry : ReplicationTable.getScanner(client)) {
-        assertFalse(filesToRemove.contains(entry.getKey().getRow().toString()));
-        actualRecords++;
+      try (var scanner = ReplicationTable.getScanner(client)) {
+        for (Entry<Key,Value> entry : scanner) {
+          assertFalse(filesToRemove.contains(entry.getKey().getRow().toString()));
+          actualRecords++;
+        }
       }
 
       assertEquals(finalNumRecords, actualRecords);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationOperationsImplIT.java
b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationOperationsImplIT.java
index 74fd078..2e3ce1e 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationOperationsImplIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationOperationsImplIT.java
@@ -393,8 +393,10 @@ public class ReplicationOperationsImplIT extends ConfigurableMacBase
{
     bw.close();
 
     log.info("Reading metadata first time");
-    for (Entry<Key,Value> e : client.createScanner(MetadataTable.NAME, Authorizations.EMPTY))
{
-      log.info("{}", e.getKey());
+    try (var scanner = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> e : scanner) {
+        log.info("{}", e.getKey());
+      }
     }
 
     final AtomicBoolean done = new AtomicBoolean(false);
@@ -427,8 +429,10 @@ public class ReplicationOperationsImplIT extends ConfigurableMacBase
{
     bw.close();
 
     log.info("Reading metadata second time");
-    for (Entry<Key,Value> e : client.createScanner(MetadataTable.NAME, Authorizations.EMPTY))
{
-      log.info("{}", e.getKey());
+    try (var scanner = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+      for (Entry<Key,Value> e : scanner) {
+        log.info("{}", e.getKey());
+      }
     }
 
     bw = ReplicationTable.getBatchWriter(client);


Mime
View raw message