You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/01/31 19:54:12 UTC

[3/5] git commit: UTF8, entrySet instead of keySet and removal of an unnecessary static var.

UTF8, entrySet instead of keySet and removal of an unnecessary static var.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/049d6cd8
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/049d6cd8
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/049d6cd8

Branch: refs/heads/2292-findbugs
Commit: 049d6cd84bbb11537eae8adac44d3cdd47d9708d
Parents: 49b86c5
Author: Josh Elser <el...@apache.org>
Authored: Fri Jan 31 13:24:11 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Fri Jan 31 13:24:11 2014 -0500

----------------------------------------------------------------------
 .../accumulo/core/client/admin/TableOperationsImpl.java      | 1 -
 .../java/org/apache/accumulo/core/trace/ZooTraceClient.java  | 3 ++-
 .../accumulo/core/util/shell/commands/ListIterCommand.java   | 6 ++++--
 .../accumulo/core/util/shell/commands/PasswdCommand.java     | 3 ++-
 .../core/util/shell/commands/QuotedStringTokenizer.java      | 3 ++-
 .../accumulo/core/util/shell/commands/SetIterCommand.java    | 2 --
 .../accumulo/core/util/shell/commands/UserCommand.java       | 3 ++-
 .../core/util/shell/commands/UserPermissionsCommand.java     | 8 ++++----
 8 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
index 307243d..448981b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsImpl.java
@@ -62,7 +62,6 @@ import org.apache.accumulo.core.client.impl.Tables;
 import org.apache.accumulo.core.client.impl.TabletLocator;
 import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation;
 import org.apache.accumulo.core.client.impl.thrift.ClientService;
-import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
 import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException;
 import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/trace/ZooTraceClient.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/ZooTraceClient.java b/core/src/main/java/org/apache/accumulo/core/trace/ZooTraceClient.java
index 9fd3e22..1315a9d 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/ZooTraceClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/ZooTraceClient.java
@@ -22,8 +22,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
-import org.apache.accumulo.trace.instrument.receivers.SendSpansViaThrift;
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
+import org.apache.accumulo.trace.instrument.receivers.SendSpansViaThrift;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
index 754e033..6001956 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ListIterCommand.java
@@ -59,8 +59,10 @@ public class ListIterCommand extends Command {
       throw new IllegalArgumentException("You must select at least one scope to configure");
     }    
     final StringBuilder sb = new StringBuilder("-\n");
-    for (String name : iterators.keySet()) {
-      for (IteratorScope scope : iterators.get(name)) {
+    for (Entry<String,EnumSet<IteratorScope>> entry : iterators.entrySet()) {
+      final String name = entry.getKey();
+      final EnumSet<IteratorScope> scopes = entry.getValue();
+      for (IteratorScope scope : scopes) {
         if (cl.hasOption(scopeOpts.get(scope).getOpt())) {
           IteratorSetting setting = shellState.getConnector().tableOperations().getIteratorSetting(tableName, name, scope);
           sb.append("-    Iterator ").append(setting.getName()).append(", ").append(scope).append(" scope options:\n");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
index aba9dd3..7a3be0c 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/PasswdCommand.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode;
@@ -63,7 +64,7 @@ public class PasswdCommand extends Command {
     if (!password.equals(passwordConfirm)) {
       throw new IllegalArgumentException("Passwords do not match");
     }
-    byte[] pass = password.getBytes();
+    byte[] pass = password.getBytes(Constants.UTF8);
     shellState.getConnector().securityOperations().changeLocalUserPassword(user, new PasswordToken(pass));
     // update the current credentials if the password changed was for
     // the current user

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
index 6872d89..b670d9d 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/QuotedStringTokenizer.java
@@ -20,6 +20,7 @@ import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.util.BadArgumentException;
 import org.apache.accumulo.core.util.shell.Shell;
 
@@ -57,7 +58,7 @@ public class QuotedStringTokenizer implements Iterable<String> {
     
     final byte[] token = new byte[input.length()];
     int tokenLength = 0;
-    final byte[] inputBytes = input.getBytes();
+    final byte[] inputBytes = input.getBytes(Constants.UTF8);
     for (int i = 0; i < input.length(); ++i) {
       final char ch = input.charAt(i);
       

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
index 26e38e6..7c71e59 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
@@ -222,8 +222,6 @@ public class SetIterCommand extends Command {
           if (input == null) {
             reader.printNewline();
             throw new IOException("Input stream closed");
-          } else {
-            input = new String(input);
           }
           // Places all Parameters and Values into the LocalOptions, even if the value is "".
           // This allows us to check for "" values when setting the iterators and allows us to remove

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
index 864b5f3..221beaf 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserCommand.java
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
@@ -43,7 +44,7 @@ public class UserCommand extends Command {
       shellState.getReader().printNewline();
       return 0;
     } // user canceled
-    pass = p.getBytes();
+    pass = p.getBytes(Constants.UTF8);
     shellState.updateUser(user, new PasswordToken(pass));
     return 0;
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/049d6cd8/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserPermissionsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserPermissionsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserPermissionsCommand.java
index 8da9742..ce0eed9 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserPermissionsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/UserPermissionsCommand.java
@@ -30,7 +30,6 @@ import org.apache.commons.cli.Options;
 
 public class UserPermissionsCommand extends Command {
   private Option userOpt;
-  private static int runOnce = 0;
   
   @Override
   public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
@@ -46,20 +45,21 @@ public class UserPermissionsCommand extends Command {
     }
     shellState.getReader().printNewline();
     
+    boolean runOnce = true;
     for (String t : shellState.getConnector().tableOperations().list()) {
       delim = "";
       for (TablePermission p : TablePermission.values()) {
         if (shellState.getConnector().securityOperations().hasTablePermission(user, t, p) && p != null) {
-          if (runOnce == 0) {
+          if (runOnce) {
             shellState.getReader().printString("\nTable permissions (" + t + "): ");
-            runOnce++;
+            runOnce = false;
           }
           shellState.getReader().printString(delim + "Table." + p.name());
           delim = ", ";
         }
         
       }
-      runOnce = 0;
+      runOnce = true;
     }
     shellState.getReader().printNewline();
     return 0;