accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [19/26] git commit: UTF8, entrySet instead of keySet and removal of an unnecessary static var.
Date Sat, 01 Feb 2014 03:23:18 GMT
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/d2dceb2d
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d2dceb2d
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d2dceb2d

Branch: refs/heads/2292-findbugs
Commit: d2dceb2dfd3fae68713c521495a77e2c1b964d56
Parents: e89d6e0
Author: Josh Elser <elserj@apache.org>
Authored: Fri Jan 31 13:24:11 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Jan 31 22:18:53 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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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/d2dceb2d/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;


Mime
View raw message