accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo] branch master updated: Fix code quality issues (#982)
Date Fri, 22 Feb 2019 21:19:07 GMT
This is an automated email from the ASF dual-hosted git repository.

mwalch 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 9056570  Fix code quality issues (#982)
9056570 is described below

commit 90565705bce67a38895e157a194ec654c3f9dfea
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Fri Feb 22 16:18:58 2019 -0500

    Fix code quality issues (#982)
    
    * Fix if statement that is always true
    * Remove resource leak
---
 .../apache/accumulo/core/client/mapred/AccumuloOutputFormat.java   | 2 +-
 .../accumulo/core/client/mapreduce/AccumuloOutputFormat.java       | 2 +-
 .../apache/accumulo/hadoopImpl/mapred/AccumuloRecordWriter.java    | 2 +-
 .../apache/accumulo/hadoopImpl/mapreduce/AccumuloRecordWriter.java | 2 +-
 shell/src/main/java/org/apache/accumulo/shell/Shell.java           | 7 ++++---
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
index 9daadcc..2db6819 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormat.java
@@ -548,7 +548,7 @@ public class AccumuloOutputFormat implements OutputFormat<Text,Mutation>
{
       try {
         mtbw.close();
       } catch (MutationsRejectedException e) {
-        if (e.getSecurityErrorCodes().size() >= 0) {
+        if (!e.getSecurityErrorCodes().isEmpty()) {
           HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<>();
           for (Entry<TabletId,Set<SecurityErrorCode>> ke : e.getSecurityErrorCodes().entrySet())
{
             String tableId = ke.getKey().getTableId().toString();
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
index 99b414f..93cc7a6 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
@@ -549,7 +549,7 @@ public class AccumuloOutputFormat extends OutputFormat<Text,Mutation>
{
       try {
         mtbw.close();
       } catch (MutationsRejectedException e) {
-        if (e.getSecurityErrorCodes().size() >= 0) {
+        if (!e.getSecurityErrorCodes().isEmpty()) {
           HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<>();
           for (Entry<TabletId,Set<SecurityErrorCode>> ke : e.getSecurityErrorCodes().entrySet())
{
             String tableId = ke.getKey().getTableId().toString();
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloRecordWriter.java
b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloRecordWriter.java
index 5ce64a3..c0371b3 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloRecordWriter.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapred/AccumuloRecordWriter.java
@@ -184,7 +184,7 @@ public class AccumuloRecordWriter implements RecordWriter<Text,Mutation>
{
     try {
       mtbw.close();
     } catch (MutationsRejectedException e) {
-      if (e.getSecurityErrorCodes().size() >= 0) {
+      if (!e.getSecurityErrorCodes().isEmpty()) {
         HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<>();
         for (Map.Entry<TabletId,Set<SecurityErrorCode>> ke : e.getSecurityErrorCodes().entrySet())
{
           String tableId = ke.getKey().getTableId().toString();
diff --git a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloRecordWriter.java
b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloRecordWriter.java
index 680d813..9818b7b 100644
--- a/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloRecordWriter.java
+++ b/hadoop-mapreduce/src/main/java/org/apache/accumulo/hadoopImpl/mapreduce/AccumuloRecordWriter.java
@@ -185,7 +185,7 @@ public class AccumuloRecordWriter extends RecordWriter<Text,Mutation>
{
     try {
       mtbw.close();
     } catch (MutationsRejectedException e) {
-      if (e.getSecurityErrorCodes().size() >= 0) {
+      if (!e.getSecurityErrorCodes().isEmpty()) {
         HashMap<String,Set<SecurityErrorCode>> tables = new HashMap<>();
         for (Map.Entry<TabletId,Set<SecurityErrorCode>> ke : e.getSecurityErrorCodes().entrySet())
{
           String tableId = ke.getKey().getTableId().toString();
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 14db16d..ada3424 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -1130,9 +1130,10 @@ public class Shell extends ShellOptions implements KeywordExecutable
{
 
   private final void printHelp(String usage, String description, Options opts, int width)
       throws IOException {
-    new HelpFormatter().printHelp(new PrintWriter(reader.getOutput()), width, usage, description,
-        opts, 2, 5, null, true);
-    reader.getOutput().flush();
+    try (PrintWriter pw = new PrintWriter(reader.getOutput())) {
+      new HelpFormatter().printHelp(pw, width, usage, description, opts, 2, 5, null, true);
+      reader.getOutput().flush();
+    }
   }
 
   public int getExitCode() {


Mime
View raw message