ctubbsii commented on a change in pull request #341: ACCUMULO-3902 Ensure 
[Batch]Scanners are closed in ITs
URL: https://github.com/apache/accumulo/pull/341#discussion_r157229274
 
 

 ##########
 File path: test/src/main/java/org/apache/accumulo/test/AuditMessageIT.java
 ##########
 @@ -428,6 +428,7 @@ public void testDeniedAudits() throws 
AccumuloSecurityException, AccumuloExcepti
     try {
       Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, 
auths);
       scanner.iterator().next().getKey();
+      scanner.close();
 
 Review comment:
   I think that in many cases like this, the following try-with-resources 
syntax is preferred:
   
   ```java
   try (Scanner scanner = auditConnector.createScanner(OLD_TEST_TABLE_NAME, 
auths)) {
     scanner.iterator().next().getKey();
   }
   ```
   
   This is a simpler syntax that doesn't require an explicit call to the 
AutoCloseable's close method.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to