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:11 UTC
[2/5] git commit: utf8 encoding,
replace unix newlines for system-dependent newlines,
add Serializable to comparator,
and avoid Long/Short constructor use when we have a primitive already.
utf8 encoding, replace unix newlines for system-dependent newlines, add Serializable to comparator, and avoid Long/Short
constructor use when we have a primitive already.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/49b86c58
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/49b86c58
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/49b86c58
Branch: refs/heads/2292-findbugs
Commit: 49b86c580f6da92ca48c956d5060a6a0bbd2e8ff
Parents: 0d38c5c
Author: Josh Elser <el...@apache.org>
Authored: Fri Jan 31 12:36:18 2014 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Fri Jan 31 12:36:18 2014 -0500
----------------------------------------------------------------------
.../core/security/ColumnVisibility.java | 38 ++++++++++----------
.../core/security/VisibilityConstraint.java | 5 +--
.../core/security/VisibilityParseException.java | 4 ++-
.../core/trace/InstanceUserPassword.java | 3 +-
.../apache/accumulo/core/trace/SpanTree.java | 2 +-
.../accumulo/core/trace/ZooTraceClient.java | 2 +-
.../core/util/ByteArrayBackedCharSequence.java | 3 +-
.../apache/accumulo/core/util/ByteArraySet.java | 4 ++-
.../accumulo/core/util/ByteBufferUtil.java | 3 +-
.../org/apache/accumulo/core/util/Encoding.java | 5 +--
.../apache/accumulo/core/util/FastFormat.java | 4 ++-
.../org/apache/accumulo/core/util/Merge.java | 2 +-
.../accumulo/core/util/MetadataTable.java | 6 ++--
.../org/apache/accumulo/core/util/TextUtil.java | 2 +-
.../apache/accumulo/core/util/shell/Shell.java | 11 +++---
.../util/shell/commands/AddSplitsCommand.java | 5 +--
.../shell/commands/AuthenticateCommand.java | 3 +-
.../util/shell/commands/CreateTableCommand.java | 5 ++-
.../util/shell/commands/ExecfileCommand.java | 3 +-
.../util/shell/commands/GetSplitsCommand.java | 4 +--
.../core/util/shell/commands/HelpCommand.java | 2 +-
.../core/util/shell/commands/HiddenCommand.java | 3 +-
22 files changed, 69 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java b/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
index 7d7daa2..bd0caba 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/ColumnVisibility.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.security;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -113,8 +114,9 @@ public class ColumnVisibility {
}
}
- public static class NodeComparator implements Comparator<Node> {
+ public static class NodeComparator implements Comparator<Node>, Serializable {
+ private static final long serialVersionUID = 1L;
byte[] text;
public NodeComparator(byte[] text) {
@@ -190,7 +192,7 @@ public class ColumnVisibility {
*/
private static void stringify(Node root, byte[] expression, StringBuilder out) {
if (root.type == NodeType.TERM) {
- out.append(new String(expression, root.start, root.end - root.start));
+ out.append(new String(expression, root.start, root.end - root.start, Constants.UTF8));
} else {
String sep = "";
for (Node c : root.children) {
@@ -215,7 +217,7 @@ public class ColumnVisibility {
Node normRoot = normalize(node, expression);
StringBuilder builder = new StringBuilder(expression.length);
stringify(normRoot, expression, builder);
- return builder.toString().getBytes();
+ return builder.toString().getBytes(Constants.UTF8);
}
private static class ColumnVisibilityParser {
@@ -228,10 +230,10 @@ public class ColumnVisibility {
if (expression.length > 0) {
Node node = parse_(expression);
if (node == null) {
- throw new BadArgumentException("operator or missing parens", new String(expression), index - 1);
+ throw new BadArgumentException("operator or missing parens", new String(expression, Constants.UTF8), index - 1);
}
if (parens != 0) {
- throw new BadArgumentException("parenthesis mis-match", new String(expression), index - 1);
+ throw new BadArgumentException("parenthesis mis-match", new String(expression, Constants.UTF8), index - 1);
}
return node;
}
@@ -241,11 +243,11 @@ public class ColumnVisibility {
Node processTerm(int start, int end, Node expr, byte[] expression) {
if (start != end) {
if (expr != null)
- throw new BadArgumentException("expression needs | or &", new String(expression), start);
+ throw new BadArgumentException("expression needs | or &", new String(expression, Constants.UTF8), start);
return new Node(start, end);
}
if (expr == null)
- throw new BadArgumentException("empty term", new String(expression), start);
+ throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), start);
return expr;
}
@@ -261,7 +263,7 @@ public class ColumnVisibility {
expr = processTerm(termStart, index - 1, expr, expression);
if (result != null) {
if (!result.type.equals(NodeType.AND))
- throw new BadArgumentException("cannot mix & and |", new String(expression), index - 1);
+ throw new BadArgumentException("cannot mix & and |", new String(expression, Constants.UTF8), index - 1);
} else {
result = new Node(NodeType.AND);
}
@@ -275,7 +277,7 @@ public class ColumnVisibility {
expr = processTerm(termStart, index - 1, expr, expression);
if (result != null) {
if (!result.type.equals(NodeType.OR))
- throw new BadArgumentException("cannot mix | and &", new String(expression), index - 1);
+ throw new BadArgumentException("cannot mix | and &", new String(expression, Constants.UTF8), index - 1);
} else {
result = new Node(NodeType.OR);
}
@@ -288,7 +290,7 @@ public class ColumnVisibility {
case '(': {
parens++;
if (termStart != index - 1 || expr != null)
- throw new BadArgumentException("expression needs & or |", new String(expression), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
expr = parse_(expression);
termStart = index;
termComplete = false;
@@ -298,7 +300,7 @@ public class ColumnVisibility {
parens--;
Node child = processTerm(termStart, index - 1, expr, expression);
if (child == null && result == null)
- throw new BadArgumentException("empty expression not allowed", new String(expression), index);
+ throw new BadArgumentException("empty expression not allowed", new String(expression, Constants.UTF8), index);
if (result == null)
return child;
if (result.type == child.type)
@@ -311,22 +313,22 @@ public class ColumnVisibility {
}
case '"': {
if (termStart != index - 1)
- throw new BadArgumentException("expression needs & or |", new String(expression), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
while (index < expression.length && expression[index] != '"') {
if (expression[index] == '\\') {
index++;
if (expression[index] != '\\' && expression[index] != '"')
- throw new BadArgumentException("invalid escaping within quotes", new String(expression), index - 1);
+ throw new BadArgumentException("invalid escaping within quotes", new String(expression, Constants.UTF8), index - 1);
}
index++;
}
if (index == expression.length)
- throw new BadArgumentException("unclosed quote", new String(expression), termStart);
+ throw new BadArgumentException("unclosed quote", new String(expression, Constants.UTF8), termStart);
if (termStart + 1 == index)
- throw new BadArgumentException("empty term", new String(expression), termStart);
+ throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), termStart);
index++;
@@ -336,11 +338,11 @@ public class ColumnVisibility {
}
default: {
if (termComplete)
- throw new BadArgumentException("expression needs & or |", new String(expression), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
byte c = expression[index - 1];
if (!Authorizations.isValidAuthChar(c))
- throw new BadArgumentException("bad character (" + c + ")", new String(expression), index - 1);
+ throw new BadArgumentException("bad character (" + c + ")", new String(expression, Constants.UTF8), index - 1);
}
}
}
@@ -351,7 +353,7 @@ public class ColumnVisibility {
result = child;
if (result.type != NodeType.TERM)
if (result.children.size() < 2)
- throw new BadArgumentException("missing term", new String(expression), index);
+ throw new BadArgumentException("missing term", new String(expression, Constants.UTF8), index);
return result;
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java b/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
index c8b33ba..94aa1a4 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/VisibilityConstraint.java
@@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.constraints.Constraint;
import org.apache.accumulo.core.data.ColumnUpdate;
import org.apache.accumulo.core.data.Mutation;
@@ -54,7 +55,7 @@ public class VisibilityConstraint implements Constraint {
byte[] cv = update.getColumnVisibility();
if (cv.length > 0) {
String key = null;
- if (ok != null && ok.contains(key = new String(cv)))
+ if (ok != null && ok.contains(key = new String(cv, Constants.UTF8)))
continue;
try {
@@ -63,7 +64,7 @@ public class VisibilityConstraint implements Constraint {
ve = new VisibilityEvaluator(env.getAuthorizations());
if (!ve.evaluate(new ColumnVisibility(cv)))
- return Collections.singletonList(new Short((short) 2));
+ return Collections.singletonList(Short.valueOf((short) 2));
} catch (BadArgumentException bae) {
return Collections.singletonList(new Short((short) 1));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java b/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
index 2f46dc9..c61faf5 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/VisibilityParseException.java
@@ -18,13 +18,15 @@ package org.apache.accumulo.core.security;
import java.text.ParseException;
+import org.apache.accumulo.core.Constants;
+
public class VisibilityParseException extends ParseException {
private static final long serialVersionUID = 1L;
private String visibility;
public VisibilityParseException(String reason, byte[] visibility, int errorOffset) {
super(reason, errorOffset);
- this.visibility = new String(visibility);
+ this.visibility = new String(visibility, Constants.UTF8);
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/trace/InstanceUserPassword.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/InstanceUserPassword.java b/core/src/main/java/org/apache/accumulo/core/trace/InstanceUserPassword.java
index e9cb439..dfda097 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/InstanceUserPassword.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/InstanceUserPassword.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.trace;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
public class InstanceUserPassword {
@@ -26,6 +27,6 @@ public class InstanceUserPassword {
public InstanceUserPassword(Instance instance, String username, String password) {
this.instance = instance;
this.username = username;
- this.password = password.getBytes();
+ this.password = password.getBytes(Constants.UTF8);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/trace/SpanTree.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/trace/SpanTree.java b/core/src/main/java/org/apache/accumulo/core/trace/SpanTree.java
index 2a5d72e..772a133 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/SpanTree.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/SpanTree.java
@@ -42,7 +42,7 @@ public class SpanTree {
public Set<Long> visit(SpanTreeVisitor visitor) {
Set<Long> visited = new HashSet<Long>();
- List<Long> root = parentChildren.get(new Long(Span.ROOT_SPAN_ID));
+ List<Long> root = parentChildren.get(Long.valueOf(Span.ROOT_SPAN_ID));
if (root == null || root.isEmpty())
return visited;
RemoteSpan rootSpan = nodes.get(root.iterator().next());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/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 43fa464..9fd3e22 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
@@ -73,7 +73,7 @@ public class ZooTraceClient extends SendSpansViaThrift implements Watcher {
List<String> hosts = new ArrayList<String>();
for (String child : children) {
byte[] data = zoo.getData(path + "/" + child, null);
- hosts.add(new String(data));
+ hosts.add(new String(data, Constants.UTF8));
}
this.hosts.clear();
this.hosts.addAll(hosts);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/ByteArrayBackedCharSequence.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ByteArrayBackedCharSequence.java b/core/src/main/java/org/apache/accumulo/core/util/ByteArrayBackedCharSequence.java
index f64b36c..e7fe974 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ByteArrayBackedCharSequence.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ByteArrayBackedCharSequence.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.core.util;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.ByteSequence;
public class ByteArrayBackedCharSequence implements CharSequence {
@@ -60,7 +61,7 @@ public class ByteArrayBackedCharSequence implements CharSequence {
}
public String toString() {
- return new String(data, offset, len);
+ return new String(data, offset, len, Constants.UTF8);
}
public void set(ByteSequence bs) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/ByteArraySet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ByteArraySet.java b/core/src/main/java/org/apache/accumulo/core/util/ByteArraySet.java
index 68f0ae5..8b71e6f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ByteArraySet.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ByteArraySet.java
@@ -22,6 +22,8 @@ import java.util.Collection;
import java.util.List;
import java.util.TreeSet;
+import org.apache.accumulo.core.Constants;
+
public class ByteArraySet extends TreeSet<byte[]> {
private static final long serialVersionUID = 1L;
@@ -38,7 +40,7 @@ public class ByteArraySet extends TreeSet<byte[]> {
public static ByteArraySet fromStrings(Collection<String> c) {
List<byte[]> lst = new ArrayList<byte[]>();
for (String s : c)
- lst.add(s.getBytes());
+ lst.add(s.getBytes(Constants.UTF8));
return new ByteArraySet(lst);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java b/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java
index 807bc95..01f76b7 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
+import org.apache.accumulo.core.Constants;
import org.apache.hadoop.io.Text;
public class ByteBufferUtil {
@@ -60,6 +61,6 @@ public class ByteBufferUtil {
}
public static String toString(ByteBuffer bytes) {
- return new String(bytes.array(), bytes.position(), bytes.remaining());
+ return new String(bytes.array(), bytes.position(), bytes.remaining(), Constants.UTF8);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Encoding.java b/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
index 1c8cb5d..451d4d6 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Encoding.java
@@ -16,13 +16,14 @@
*/
package org.apache.accumulo.core.util;
+import org.apache.accumulo.core.Constants;
import org.apache.commons.codec.binary.Base64;
import org.apache.hadoop.io.Text;
public class Encoding {
public static String encodeAsBase64FileName(Text data) {
- String encodedRow = new String(Base64.encodeBase64(TextUtil.getBytes(data)));
+ String encodedRow = new String(Base64.encodeBase64(TextUtil.getBytes(data)), Constants.UTF8);
encodedRow = encodedRow.replace('/', '_').replace('+', '-');
int index = encodedRow.length() - 1;
@@ -39,7 +40,7 @@ public class Encoding {
node = node.replace('_', '/').replace('-', '+');
- return Base64.decodeBase64(node.getBytes());
+ return Base64.decodeBase64(node.getBytes(Constants.UTF8));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java b/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
index 496ca95..8c3e416 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/FastFormat.java
@@ -16,12 +16,14 @@
*/
package org.apache.accumulo.core.util;
+import org.apache.accumulo.core.Constants;
+
public class FastFormat {
// this 7 to 8 times faster than String.format("%s%06d",prefix, num)
public static byte[] toZeroPaddedString(long num, int width, int radix, byte[] prefix) {
byte ret[] = new byte[width + prefix.length];
if (toZeroPaddedString(ret, 0, num, width, radix, prefix) != ret.length)
- throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix));
+ throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, Constants.UTF8));
return ret;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/Merge.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Merge.java b/core/src/main/java/org/apache/accumulo/core/util/Merge.java
index 5ec7a9a..b6cb07f 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Merge.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Merge.java
@@ -233,7 +233,7 @@ public class Merge {
Entry<Key,Value> entry = iterator.next();
Key key = entry.getKey();
if (key.getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
- String[] sizeEntries = new String(entry.getValue().get()).split(",");
+ String[] sizeEntries = new String(entry.getValue().get(), Constants.UTF8).split(",");
if (sizeEntries.length == 2) {
tabletSize += Long.parseLong(sizeEntries[0]);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/MetadataTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/MetadataTable.java b/core/src/main/java/org/apache/accumulo/core/util/MetadataTable.java
index e94ef35..fdc7eef 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/MetadataTable.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/MetadataTable.java
@@ -61,7 +61,7 @@ public class MetadataTable {
}
public DataFileValue(byte[] encodedDFV) {
- String[] ba = new String(encodedDFV).split(",");
+ String[] ba = new String(encodedDFV, Constants.UTF8).split(",");
size = Long.parseLong(ba[0]);
numEntries = Long.parseLong(ba[1]);
@@ -90,8 +90,8 @@ public class MetadataTable {
public byte[] encode() {
if (time >= 0)
- return ("" + size + "," + numEntries + "," + time).getBytes();
- return ("" + size + "," + numEntries).getBytes();
+ return ("" + size + "," + numEntries + "," + time).getBytes(Constants.UTF8);
+ return ("" + size + "," + numEntries).getBytes(Constants.UTF8);
}
public boolean equals(Object o) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java b/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
index f78747e..45bbe00 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/TextUtil.java
@@ -43,7 +43,7 @@ public final class TextUtil {
Text newText = new Text();
newText.append(text.getBytes(), 0, maxLen);
String suffix = "... TRUNCATED";
- newText.append(suffix.getBytes(), 0, suffix.length());
+ newText.append(suffix.getBytes(Constants.UTF8), 0, suffix.length());
return newText;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
index 7efe5e6..656f2ae 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
@@ -16,9 +16,12 @@
*/
package org.apache.accumulo.core.util.shell;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.util.Arrays;
@@ -437,7 +440,7 @@ public class Shell extends ShellOptions {
ShellCompletor userCompletor = null;
if (execFile != null) {
- java.util.Scanner scanner = new java.util.Scanner(new File(execFile));
+ java.util.Scanner scanner = new java.util.Scanner(new File(execFile), Constants.UTF8.name());
try {
while (scanner.hasNextLine() && !hasExited()) {
execCommand(scanner.nextLine(), true, isVerbose());
@@ -542,7 +545,7 @@ public class Shell extends ShellOptions {
// Obtain the command from the command table
sc = commandFactory.get(command);
if (sc == null) {
- reader.printString(String.format("Unknown command \"%s\". Enter \"help\" for a list possible commands.\n", command));
+ reader.printString(String.format("Unknown command \"%s\". Enter \"help\" for a list possible commands.%n", command));
reader.flushConsole();
return;
}
@@ -805,7 +808,7 @@ public class Shell extends ShellOptions {
PrintWriter writer;
public PrintFile(String filename) throws FileNotFoundException {
- writer = new PrintWriter(filename);
+ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), Constants.UTF8)));
}
@Override
@@ -940,7 +943,7 @@ public class Shell extends ShellOptions {
}
private final void printHelp(String usage, String description, Options opts, int width) {
- PrintWriter pw = new PrintWriter(System.err);
+ PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.err, Constants.UTF8));
new HelpFormatter().printHelp(pw, width, usage, description, opts, 2, 5, null, true);
pw.flush();
if (logErrorsToConsole && writer != null) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
index 44cbd35..6bd260c 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AddSplitsCommand.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util.shell.commands;
import java.io.File;
import java.util.TreeSet;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
@@ -42,11 +43,11 @@ public class AddSplitsCommand extends Command {
final String f = cl.getOptionValue(optSplitsFile.getOpt());
String line;
- java.util.Scanner file = new java.util.Scanner(new File(f));
+ java.util.Scanner file = new java.util.Scanner(new File(f), Constants.UTF8.name());
while (file.hasNextLine()) {
line = file.nextLine();
if (!line.isEmpty()) {
- splits.add(decode ? new Text(Base64.decodeBase64(line.getBytes())) : new Text(line));
+ splits.add(decode ? new Text(Base64.decodeBase64(line.getBytes(Constants.UTF8))) : new Text(line));
}
}
} else {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java
index ae7854b..5266337 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/AuthenticateCommand.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;
@@ -37,7 +38,7 @@ public class AuthenticateCommand extends Command {
shellState.getReader().printNewline();
return 0;
} // user canceled
- final byte[] password = p.getBytes();
+ final byte[] password = p.getBytes(Constants.UTF8);
final boolean valid = shellState.getConnector().securityOperations().authenticateUser(user, new PasswordToken(password));
shellState.getReader().printString((valid ? "V" : "Not v") + "alid\n");
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
index c439909..b476ae4 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/CreateTableCommand.java
@@ -51,7 +51,6 @@ public class CreateTableCommand extends Command {
private Option createTableOptEVC;
private Option base64Opt;
private Option createTableOptFormatter;
- public static String testTable;
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, TableExistsException,
TableNotFoundException, IOException, ClassNotFoundException {
@@ -74,12 +73,12 @@ public class CreateTableCommand extends Command {
final String f = cl.getOptionValue(createTableOptSplit.getOpt());
String line;
- Scanner file = new Scanner(new File(f));
+ Scanner file = new Scanner(new File(f), Constants.UTF8.name());
try {
while (file.hasNextLine()) {
line = file.nextLine();
if (!line.isEmpty())
- partitions.add(decode ? new Text(Base64.decodeBase64(line.getBytes())) : new Text(line));
+ partitions.add(decode ? new Text(Base64.decodeBase64(line.getBytes(Constants.UTF8 ))) : new Text(line));
}
} finally {
file.close();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
index a9c409f..5fa5b10 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/ExecfileCommand.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util.shell.commands;
import java.io.File;
import java.util.Scanner;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
@@ -35,7 +36,7 @@ public class ExecfileCommand extends Command {
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
- Scanner scanner = new Scanner(new File(cl.getArgs()[0]));
+ Scanner scanner = new Scanner(new File(cl.getArgs()[0]), Constants.UTF8.name());
try {
while (scanner.hasNextLine()) {
shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt()));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
index 12c17cb..635d0ff 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetSplitsCommand.java
@@ -99,7 +99,7 @@ public class GetSplitsCommand extends Command {
return null;
}
BinaryFormatter.getlength(text.getLength());
- return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text))) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
+ return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text)), Constants.UTF8) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
}
private static String obscuredTabletName(final KeyExtent extent) {
@@ -112,7 +112,7 @@ public class GetSplitsCommand extends Command {
if (extent.getEndRow() != null && extent.getEndRow().getLength() > 0) {
digester.update(extent.getEndRow().getBytes(), 0, extent.getEndRow().getLength());
}
- return new String(Base64.encodeBase64(digester.digest()));
+ return new String(Base64.encodeBase64(digester.digest()), Constants.UTF8);
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
index 1967dce..765fdc4 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HelpCommand.java
@@ -91,7 +91,7 @@ public class HelpCommand extends Command {
for (String cmd : cl.getArgs()) {
final Command c = shellState.commandFactory.get(cmd);
if (c == null) {
- shellState.getReader().printString(String.format("Unknown command \"%s\". Enter \"help\" for a list possible commands.\n", cmd));
+ shellState.getReader().printString(String.format("Unknown command \"%s\". Enter \"help\" for a list possible commands.%n", cmd));
} else {
c.printHelp(shellState, numColumns);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/49b86c58/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
index 0413d73..37b9ec0 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/HiddenCommand.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.util.shell.commands;
import java.security.SecureRandom;
import java.util.Random;
+import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.accumulo.core.util.shell.ShellCommandException;
@@ -42,7 +43,7 @@ public class HiddenCommand extends Command {
shellState.getReader().printString(
new String(Base64.decodeBase64(("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
+ "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
- + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes())));
+ + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes()), Constants.UTF8));
shellState.getReader().printNewline();
} else {
throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());