You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2014/04/03 00:54:31 UTC
[4/5] ACCUMULO-1545 Replace UTF8 constant with built-in one
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 75091d2..16cb515 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
@@ -17,6 +17,7 @@
package org.apache.accumulo.core.security;
import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -24,7 +25,6 @@ import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.accumulo.core.util.BadArgumentException;
@@ -213,7 +213,7 @@ public class ColumnVisibility {
*/
public 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, Constants.UTF8));
+ out.append(new String(expression, root.start, root.end - root.start, StandardCharsets.UTF_8));
} else {
String sep = "";
for (Node c : root.children) {
@@ -238,7 +238,7 @@ public class ColumnVisibility {
Node normRoot = normalize(node, expression);
StringBuilder builder = new StringBuilder(expression.length);
stringify(normRoot, expression, builder);
- return builder.toString().getBytes(Constants.UTF8);
+ return builder.toString().getBytes(StandardCharsets.UTF_8);
}
private static class ColumnVisibilityParser {
@@ -251,10 +251,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, Constants.UTF8), index - 1);
+ throw new BadArgumentException("operator or missing parens", new String(expression, StandardCharsets.UTF_8), index - 1);
}
if (parens != 0) {
- throw new BadArgumentException("parenthesis mis-match", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("parenthesis mis-match", new String(expression, StandardCharsets.UTF_8), index - 1);
}
return node;
}
@@ -264,11 +264,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, Constants.UTF8), start);
+ throw new BadArgumentException("expression needs | or &", new String(expression, StandardCharsets.UTF_8), start);
return new Node(start, end);
}
if (expr == null)
- throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), start);
+ throw new BadArgumentException("empty term", new String(expression, StandardCharsets.UTF_8), start);
return expr;
}
@@ -285,7 +285,7 @@ public class ColumnVisibility {
expr = processTerm(subtermStart, index - 1, expr, expression);
if (result != null) {
if (!result.type.equals(NodeType.AND))
- throw new BadArgumentException("cannot mix & and |", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("cannot mix & and |", new String(expression, StandardCharsets.UTF_8), index - 1);
} else {
result = new Node(NodeType.AND, wholeTermStart);
}
@@ -299,7 +299,7 @@ public class ColumnVisibility {
expr = processTerm(subtermStart, index - 1, expr, expression);
if (result != null) {
if (!result.type.equals(NodeType.OR))
- throw new BadArgumentException("cannot mix | and &", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("cannot mix | and &", new String(expression, StandardCharsets.UTF_8), index - 1);
} else {
result = new Node(NodeType.OR, wholeTermStart);
}
@@ -312,7 +312,7 @@ public class ColumnVisibility {
case '(': {
parens++;
if (subtermStart != index - 1 || expr != null)
- throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, StandardCharsets.UTF_8), index - 1);
expr = parse_(expression);
subtermStart = index;
subtermComplete = false;
@@ -322,7 +322,7 @@ public class ColumnVisibility {
parens--;
Node child = processTerm(subtermStart, index - 1, expr, expression);
if (child == null && result == null)
- throw new BadArgumentException("empty expression not allowed", new String(expression, Constants.UTF8), index);
+ throw new BadArgumentException("empty expression not allowed", new String(expression, StandardCharsets.UTF_8), index);
if (result == null)
return child;
if (result.type == child.type)
@@ -335,22 +335,22 @@ public class ColumnVisibility {
}
case '"': {
if (subtermStart != index - 1)
- throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, StandardCharsets.UTF_8), 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, Constants.UTF8), index - 1);
+ throw new BadArgumentException("invalid escaping within quotes", new String(expression, StandardCharsets.UTF_8), index - 1);
}
index++;
}
if (index == expression.length)
- throw new BadArgumentException("unclosed quote", new String(expression, Constants.UTF8), subtermStart);
+ throw new BadArgumentException("unclosed quote", new String(expression, StandardCharsets.UTF_8), subtermStart);
if (subtermStart + 1 == index)
- throw new BadArgumentException("empty term", new String(expression, Constants.UTF8), subtermStart);
+ throw new BadArgumentException("empty term", new String(expression, StandardCharsets.UTF_8), subtermStart);
index++;
@@ -360,11 +360,11 @@ public class ColumnVisibility {
}
default: {
if (subtermComplete)
- throw new BadArgumentException("expression needs & or |", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("expression needs & or |", new String(expression, StandardCharsets.UTF_8), index - 1);
byte c = expression[index - 1];
if (!Authorizations.isValidAuthChar(c))
- throw new BadArgumentException("bad character (" + c + ")", new String(expression, Constants.UTF8), index - 1);
+ throw new BadArgumentException("bad character (" + c + ")", new String(expression, StandardCharsets.UTF_8), index - 1);
}
}
}
@@ -376,7 +376,7 @@ public class ColumnVisibility {
result = child;
if (result.type != NodeType.TERM)
if (result.children.size() < 2)
- throw new BadArgumentException("missing term", new String(expression, Constants.UTF8), index);
+ throw new BadArgumentException("missing term", new String(expression, StandardCharsets.UTF_8), index);
return result;
}
}
@@ -439,7 +439,7 @@ public class ColumnVisibility {
*
*/
public ColumnVisibility(String expression) {
- this(expression.getBytes(Constants.UTF8));
+ this(expression.getBytes(StandardCharsets.UTF_8));
}
/**
@@ -464,7 +464,7 @@ public class ColumnVisibility {
@Override
public String toString() {
- return "[" + new String(expression, Constants.UTF8) + "]";
+ return "[" + new String(expression, StandardCharsets.UTF_8) + "]";
}
/**
@@ -519,7 +519,7 @@ public class ColumnVisibility {
* @return quoted term (unquoted if unnecessary)
*/
public static String quote(String term) {
- return new String(quote(term.getBytes(Constants.UTF8)), Constants.UTF8);
+ return new String(quote(term.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
}
/**
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/Credentials.java b/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
index 5afc6e8..a95ee7d 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/Credentials.java
@@ -17,8 +17,8 @@
package org.apache.accumulo.core.security;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
@@ -97,8 +97,8 @@ public class Credentials {
* @return serialized form of these credentials
*/
public final String serialize() {
- return (getPrincipal() == null ? "-" : Base64.encodeBase64String(getPrincipal().getBytes(Constants.UTF8))) + ":"
- + (getToken() == null ? "-" : Base64.encodeBase64String(getToken().getClass().getName().getBytes(Constants.UTF8))) + ":"
+ return (getPrincipal() == null ? "-" : Base64.encodeBase64String(getPrincipal().getBytes(StandardCharsets.UTF_8))) + ":"
+ + (getToken() == null ? "-" : Base64.encodeBase64String(getToken().getClass().getName().getBytes(StandardCharsets.UTF_8))) + ":"
+ (getToken() == null ? "-" : Base64.encodeBase64String(AuthenticationTokenSerializer.serialize(getToken())));
}
@@ -111,8 +111,8 @@ public class Credentials {
*/
public static final Credentials deserialize(String serializedForm) {
String[] split = serializedForm.split(":", 3);
- String principal = split[0].equals("-") ? null : new String(Base64.decodeBase64(split[0]), Constants.UTF8);
- String tokenType = split[1].equals("-") ? null : new String(Base64.decodeBase64(split[1]), Constants.UTF8);
+ String principal = split[0].equals("-") ? null : new String(Base64.decodeBase64(split[0]), StandardCharsets.UTF_8);
+ String tokenType = split[1].equals("-") ? null : new String(Base64.decodeBase64(split[1]), StandardCharsets.UTF_8);
AuthenticationToken token = null;
if (!split[2].equals("-")) {
byte[] tokenBytes = Base64.decodeBase64(split[2]);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 8613ca7..1d29119 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
@@ -16,11 +16,11 @@
*/
package org.apache.accumulo.core.security;
+import java.nio.charset.StandardCharsets;
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;
@@ -64,7 +64,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, Constants.UTF8)))
+ if (ok != null && ok.contains(key = new String(cv, StandardCharsets.UTF_8)))
continue;
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 be5f008..1d54ae4 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
@@ -16,10 +16,9 @@
*/
package org.apache.accumulo.core.security;
+import java.nio.charset.StandardCharsets;
import java.text.ParseException;
-import org.apache.accumulo.core.Constants;
-
/**
* An exception thrown when a visibility string cannot be parsed.
*/
@@ -36,7 +35,7 @@ public class VisibilityParseException extends ParseException {
*/
public VisibilityParseException(String reason, byte[] visibility, int errorOffset) {
super(reason, errorOffset);
- this.visibility = new String(visibility, Constants.UTF8);
+ this.visibility = new String(visibility, StandardCharsets.UTF_8);
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 dfda097..2ce229c 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,7 +16,8 @@
*/
package org.apache.accumulo.core.trace;
-import org.apache.accumulo.core.Constants;
+import java.nio.charset.StandardCharsets;
+
import org.apache.accumulo.core.client.Instance;
public class InstanceUserPassword {
@@ -27,6 +28,6 @@ public class InstanceUserPassword {
public InstanceUserPassword(Instance instance, String username, String password) {
this.instance = instance;
this.username = username;
- this.password = password.getBytes(Constants.UTF8);
+ this.password = password.getBytes(StandardCharsets.UTF_8);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 1315a9d..4c8b837 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
@@ -17,12 +17,12 @@
package org.apache.accumulo.core.trace;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
-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;
@@ -74,7 +74,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, Constants.UTF8));
+ hosts.add(new String(data, StandardCharsets.UTF_8));
}
this.hosts.clear();
this.hosts.addAll(hosts);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 e7fe974..b3ebae4 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,7 +16,8 @@
*/
package org.apache.accumulo.core.util;
-import org.apache.accumulo.core.Constants;
+import java.nio.charset.StandardCharsets;
+
import org.apache.accumulo.core.data.ByteSequence;
public class ByteArrayBackedCharSequence implements CharSequence {
@@ -61,7 +62,7 @@ public class ByteArrayBackedCharSequence implements CharSequence {
}
public String toString() {
- return new String(data, offset, len, Constants.UTF8);
+ return new String(data, offset, len, StandardCharsets.UTF_8);
}
public void set(ByteSequence bs) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 8b71e6f..fc3c114 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
@@ -16,14 +16,13 @@
*/
package org.apache.accumulo.core.util;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
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;
@@ -40,7 +39,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(Constants.UTF8));
+ lst.add(s.getBytes(StandardCharsets.UTF_8));
return new ByteArraySet(lst);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 7a23c37..1a34628 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
@@ -17,12 +17,12 @@
package org.apache.accumulo.core.util;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.ByteSequence;
import org.apache.hadoop.io.Text;
@@ -62,7 +62,7 @@ public class ByteBufferUtil {
}
public static String toString(ByteBuffer bytes) {
- return new String(bytes.array(), bytes.position(), bytes.remaining(), Constants.UTF8);
+ return new String(bytes.array(), bytes.position(), bytes.remaining(), StandardCharsets.UTF_8);
}
public static ByteBuffer toByteBuffers(ByteSequence bs) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
index cc6762a..2920659 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
@@ -20,10 +20,10 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
import jline.console.ConsoleReader;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.ClientOpts.Password;
import org.apache.accumulo.core.cli.ClientOpts.PasswordConverter;
import org.apache.accumulo.core.cli.Help;
@@ -105,7 +105,7 @@ public class CreateToken {
if (!tf.exists()) {
tf.createNewFile();
}
- PrintStream out = new PrintStream(new FileOutputStream(tf, true), true, Constants.UTF8.name());
+ PrintStream out = new PrintStream(new FileOutputStream(tf, true), true, StandardCharsets.UTF_8.name());
String outString = principal + ":" + opts.tokenClassName + ":" + tokenBase64;
out.println(outString);
out.close();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 451d4d6..7ddb029 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,14 +16,15 @@
*/
package org.apache.accumulo.core.util;
-import org.apache.accumulo.core.Constants;
+import java.nio.charset.StandardCharsets;
+
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)), Constants.UTF8);
+ String encodedRow = new String(Base64.encodeBase64(TextUtil.getBytes(data)), StandardCharsets.UTF_8);
encodedRow = encodedRow.replace('/', '_').replace('+', '-');
int index = encodedRow.length() - 1;
@@ -40,7 +41,7 @@ public class Encoding {
node = node.replace('_', '/').replace('-', '+');
- return Base64.decodeBase64(node.getBytes(Constants.UTF8));
+ return Base64.decodeBase64(node.getBytes(StandardCharsets.UTF_8));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 8c3e416..7b84dc8 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,14 +16,14 @@
*/
package org.apache.accumulo.core.util;
-import org.apache.accumulo.core.Constants;
+import java.nio.charset.StandardCharsets;
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, Constants.UTF8));
+ throw new RuntimeException(" Did not format to expected width " + num + " " + width + " " + radix + " " + new String(prefix, StandardCharsets.UTF_8));
return ret;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 f268160..4c0a3ea 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
@@ -16,12 +16,12 @@
*/
package org.apache.accumulo.core.util;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.ClientOnRequiredTable;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Scanner;
@@ -238,7 +238,7 @@ public class Merge {
Entry<Key,Value> entry = iterator.next();
Key key = entry.getKey();
if (key.getColumnFamily().equals(DataFileColumnFamily.NAME)) {
- String[] sizeEntries = new String(entry.getValue().get(), Constants.UTF8).split(",");
+ String[] sizeEntries = new String(entry.getValue().get(), StandardCharsets.UTF_8).split(",");
if (sizeEntries.length == 2) {
tabletSize += Long.parseLong(sizeEntries[0]);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java b/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
index 1ebbf13..90268ef 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/MonitorUtil.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.core.util;
+import java.nio.charset.StandardCharsets;
+
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -26,6 +28,6 @@ public class MonitorUtil {
public static String getLocation(Instance instance) throws KeeperException, InterruptedException {
ZooReader zr = new ZooReader(instance.getZooKeepers(), 5000);
byte[] loc = zr.getData(ZooUtil.getRoot(instance) + Constants.ZMONITOR_HTTP_ADDR, null);
- return loc==null ? null : new String(loc, Constants.UTF8);
+ return loc==null ? null : new String(loc, StandardCharsets.UTF_8);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 45bbe00..a57839b 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
@@ -17,6 +17,7 @@
package org.apache.accumulo.core.util;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import org.apache.accumulo.core.Constants;
import org.apache.hadoop.io.Text;
@@ -43,7 +44,7 @@ public final class TextUtil {
Text newText = new Text();
newText.append(text.getBytes(), 0, maxLen);
String suffix = "... TRUNCATED";
- newText.append(suffix.getBytes(Constants.UTF8), 0, suffix.length());
+ newText.append(suffix.getBytes(StandardCharsets.UTF_8), 0, suffix.length());
return newText;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 ff6ba09..f481395 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
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -505,7 +506,7 @@ public class Shell extends ShellOptions {
ShellCompletor userCompletor = null;
if (execFile != null) {
- java.util.Scanner scanner = new java.util.Scanner(execFile, Constants.UTF8.name());
+ java.util.Scanner scanner = new java.util.Scanner(execFile, StandardCharsets.UTF_8.name());
try {
while (scanner.hasNextLine() && !hasExited()) {
execCommand(scanner.nextLine(), true, isVerbose());
@@ -919,7 +920,7 @@ public class Shell extends ShellOptions {
PrintWriter writer;
public PrintFile(String filename) throws FileNotFoundException {
- writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), Constants.UTF8)));
+ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), StandardCharsets.UTF_8)));
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/main/java/org/apache/accumulo/core/util/shell/ShellUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellUtil.java b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellUtil.java
index 4f255eb..f0dd505 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/ShellUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/ShellUtil.java
@@ -18,10 +18,10 @@ package org.apache.accumulo.core.util.shell;
import java.io.File;
import java.io.FileNotFoundException;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Scanner;
-import org.apache.accumulo.core.Constants;
import org.apache.commons.codec.binary.Base64;
import org.apache.hadoop.io.Text;
@@ -43,13 +43,13 @@ public class ShellUtil {
*/
public static List<Text> scanFile(String filename, boolean decode) throws FileNotFoundException {
String line;
- Scanner file = new Scanner(new File(filename), Constants.UTF8.name());
+ Scanner file = new Scanner(new File(filename), StandardCharsets.UTF_8.name());
List<Text> result = Lists.newArrayList();
try {
while (file.hasNextLine()) {
line = file.nextLine();
if (!line.isEmpty()) {
- result.add(decode ? new Text(Base64.decodeBase64(line.getBytes(Constants.UTF8))) : new Text(line));
+ result.add(decode ? new Text(Base64.decodeBase64(line.getBytes(StandardCharsets.UTF_8))) : new Text(line));
}
}
} finally {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 bcb6c24..8ebdae8 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
@@ -17,10 +17,10 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
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;
@@ -38,7 +38,7 @@ public class AuthenticateCommand extends Command {
shellState.getReader().println();
return 0;
} // user canceled
- final byte[] password = p.getBytes(Constants.UTF8);
+ final byte[] password = p.getBytes(StandardCharsets.UTF_8);
final boolean valid = shellState.getConnector().securityOperations().authenticateUser(user, new PasswordToken(password));
shellState.getReader().println((valid ? "V" : "Not v") + "alid");
return 0;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 5fa5b10..f4a2632 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
@@ -17,9 +17,9 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.File;
+import java.nio.charset.StandardCharsets;
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;
@@ -36,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]), Constants.UTF8.name());
+ Scanner scanner = new Scanner(new File(cl.getArgs()[0]), StandardCharsets.UTF_8.name());
try {
while (scanner.hasNextLine()) {
shellState.execCommand(scanner.nextLine(), true, cl.hasOption(verboseOption.getOpt()));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 a27fa47..92c7c5d 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
@@ -17,12 +17,12 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
import java.util.Map.Entry;
-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.Scanner;
@@ -104,7 +104,7 @@ public class GetSplitsCommand extends Command {
return null;
}
BinaryFormatter.getlength(text.getLength());
- return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text)), Constants.UTF8) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
+ return encode ? new String(Base64.encodeBase64(TextUtil.getBytes(text)), StandardCharsets.UTF_8) : BinaryFormatter.appendText(new StringBuilder(), text).toString();
}
private static String obscuredTabletName(final KeyExtent extent) {
@@ -117,7 +117,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()), Constants.UTF8);
+ return new String(Base64.encodeBase64(digester.digest()), StandardCharsets.UTF_8);
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 c212c75..c1615ea 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
@@ -16,10 +16,10 @@
*/
package org.apache.accumulo.core.util.shell.commands;
+import java.nio.charset.StandardCharsets;
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;
@@ -43,7 +43,7 @@ public class HiddenCommand extends Command {
shellState.getReader().println(
new String(Base64.decodeBase64(("ICAgICAgIC4tLS4KICAgICAgLyAvXCBcCiAgICAgKCAvLS1cICkKICAgICAuPl8gIF88LgogICAgLyB8ICd8ICcgXAog"
+ "ICAvICB8Xy58Xy4gIFwKICAvIC98ICAgICAgfFwgXAogfCB8IHwgfFwvfCB8IHwgfAogfF98IHwgfCAgfCB8IHxffAogICAgIC8gIF9fICBcCiAgICAvICAv"
- + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes(Constants.UTF8)), Constants.UTF8));
+ + "ICBcICBcCiAgIC8gIC8gICAgXCAgXF8KIHwvICAvICAgICAgXCB8IHwKIHxfXy8gICAgICAgIFx8X3wK").getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8));
} else {
throw new ShellCommandException(ErrorCode.UNRECOGNIZED_COMMAND, getName());
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 a345446..86446a2 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
@@ -17,8 +17,8 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
-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;
@@ -64,7 +64,7 @@ public class PasswdCommand extends Command {
if (!password.equals(passwordConfirm)) {
throw new IllegalArgumentException("Passwords do not match");
}
- byte[] pass = password.getBytes(Constants.UTF8);
+ byte[] pass = password.getBytes(StandardCharsets.UTF_8);
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/f8ca8d34/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 b670d9d..76ebb8f 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
@@ -17,10 +17,10 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
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;
@@ -58,7 +58,7 @@ public class QuotedStringTokenizer implements Iterable<String> {
final byte[] token = new byte[input.length()];
int tokenLength = 0;
- final byte[] inputBytes = input.getBytes(Constants.UTF8);
+ final byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8);
for (int i = 0; i < input.length(); ++i) {
final char ch = input.charAt(i);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/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 a0743f4..07da450 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
@@ -17,10 +17,10 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
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;
@@ -44,7 +44,7 @@ public class UserCommand extends Command {
shellState.getReader().println();
return 0;
} // user canceled
- pass = p.getBytes(Constants.UTF8);
+ pass = p.getBytes(StandardCharsets.UTF_8);
shellState.updateUser(user, new PasswordToken(pass));
return 0;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
index 26f23a5..7801f4d 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
@@ -24,9 +24,9 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
-import org.apache.accumulo.core.Constants;
import org.junit.Test;
/**
@@ -147,7 +147,7 @@ public class BatchWriterConfigTest {
bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(42);
bytes = createBytes(bwConfig);
- assertEquals(" i#maxWriteThreads=42", new String(bytes, Constants.UTF8));
+ assertEquals(" i#maxWriteThreads=42", new String(bytes, StandardCharsets.UTF_8));
checkBytes(bwConfig, bytes);
// test human-readable with 2 fields
@@ -155,7 +155,7 @@ public class BatchWriterConfigTest {
bwConfig.setMaxWriteThreads(24);
bwConfig.setTimeout(3, TimeUnit.SECONDS);
bytes = createBytes(bwConfig);
- assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, Constants.UTF8));
+ assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, StandardCharsets.UTF_8));
checkBytes(bwConfig, bytes);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java b/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
index 009be17..d78e3e5 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mock/MockNamespacesTest.java
@@ -21,12 +21,12 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Random;
-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.BatchWriter;
@@ -274,7 +274,7 @@ public class MockNamespacesTest {
BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
Mutation m = new Mutation("r");
- m.put("a", "b", new Value("abcde".getBytes(Constants.UTF8)));
+ m.put("a", "b", new Value("abcde".getBytes(StandardCharsets.UTF_8)));
bw.addMutation(m);
bw.flush();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/client/security/tokens/PasswordTokenTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/security/tokens/PasswordTokenTest.java b/core/src/test/java/org/apache/accumulo/core/client/security/tokens/PasswordTokenTest.java
index fbbdb9f..a3ce8d4 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/security/tokens/PasswordTokenTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/security/tokens/PasswordTokenTest.java
@@ -16,9 +16,10 @@
*/
package org.apache.accumulo.core.client.security.tokens;
+import java.nio.charset.StandardCharsets;
+
import javax.security.auth.DestroyFailedException;
-import org.apache.accumulo.core.Constants;
import org.junit.Assert;
import org.junit.Test;
@@ -34,11 +35,11 @@ public class PasswordTokenTest {
props.put("password", "五六");
pt.init(props);
props.destroy();
- String s = new String(pt.getPassword(), Constants.UTF8);
+ String s = new String(pt.getPassword(), StandardCharsets.UTF_8);
Assert.assertEquals("五六", s);
pt = new PasswordToken("五六");
- s = new String(pt.getPassword(), Constants.UTF8);
+ s = new String(pt.getPassword(), StandardCharsets.UTF_8);
Assert.assertEquals("五六", s);
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
index 3570610..8672836 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionTest.java
@@ -21,7 +21,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import org.apache.accumulo.core.Constants;
+import java.nio.charset.StandardCharsets;
+
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;
@@ -41,7 +42,7 @@ public class ConditionTest {
if (bs == null) {
return null;
}
- return new String(bs.toArray(), Constants.UTF8);
+ return new String(bs.toArray(), StandardCharsets.UTF_8);
}
private Condition c;
@@ -60,7 +61,7 @@ public class ConditionTest {
@Test
public void testConstruction_ByteArray() {
- c = new Condition(FAMILY.getBytes(Constants.UTF8), QUALIFIER.getBytes(Constants.UTF8));
+ c = new Condition(FAMILY.getBytes(StandardCharsets.UTF_8), QUALIFIER.getBytes(StandardCharsets.UTF_8));
assertEquals(FAMILY, toString(c.getFamily()));
assertEquals(QUALIFIER, toString(c.getQualifier()));
assertEquals(EMPTY, c.getVisibility());
@@ -76,7 +77,7 @@ public class ConditionTest {
@Test
public void testConstruction_ByteSequence() {
- c = new Condition(new ArrayByteSequence(FAMILY.getBytes(Constants.UTF8)), new ArrayByteSequence(QUALIFIER.getBytes(Constants.UTF8)));
+ c = new Condition(new ArrayByteSequence(FAMILY.getBytes(StandardCharsets.UTF_8)), new ArrayByteSequence(QUALIFIER.getBytes(StandardCharsets.UTF_8)));
assertEquals(FAMILY, toString(c.getFamily()));
assertEquals(QUALIFIER, toString(c.getQualifier()));
assertEquals(EMPTY, c.getVisibility());
@@ -96,7 +97,7 @@ public class ConditionTest {
@Test
public void testSetValue_ByteArray() {
- c.setValue(VALUE.getBytes(Constants.UTF8));
+ c.setValue(VALUE.getBytes(StandardCharsets.UTF_8));
assertEquals(VALUE, toString(c.getValue()));
}
@@ -108,7 +109,7 @@ public class ConditionTest {
@Test
public void testSetValue_ByteSequence() {
- c.setValue(new ArrayByteSequence(VALUE.getBytes(Constants.UTF8)));
+ c.setValue(new ArrayByteSequence(VALUE.getBytes(StandardCharsets.UTF_8)));
assertEquals(VALUE, toString(c.getValue()));
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
index 47f44f1..591baaa 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/ConditionalMutationTest.java
@@ -21,15 +21,15 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.nio.charset.StandardCharsets;
import java.util.List;
-import org.apache.accumulo.core.Constants;
import org.apache.hadoop.io.Text;
import org.junit.Before;
import org.junit.Test;
public class ConditionalMutationTest {
- private static final byte[] ROW = "row".getBytes(Constants.UTF8);
+ private static final byte[] ROW = "row".getBytes(StandardCharsets.UTF_8);
private static final String FAMILY = "family";
private static final String QUALIFIER = "qualifier";
private static final String QUALIFIER2 = "qualifier2";
@@ -58,7 +58,7 @@ public class ConditionalMutationTest {
@Test
public void testConstruction_ByteArray_StartAndLength() {
cm = new ConditionalMutation(ROW, 1, 1, c1, c2);
- assertArrayEquals("o".getBytes(Constants.UTF8), cm.getRow());
+ assertArrayEquals("o".getBytes(StandardCharsets.UTF_8), cm.getRow());
List<Condition> cs = cm.getConditions();
assertEquals(2, cs.size());
assertEquals(c1, cs.get(0));
@@ -77,7 +77,7 @@ public class ConditionalMutationTest {
@Test
public void testConstruction_CharSequence() {
- cm = new ConditionalMutation(new String(ROW, Constants.UTF8), c1, c2);
+ cm = new ConditionalMutation(new String(ROW, StandardCharsets.UTF_8), c1, c2);
assertArrayEquals(ROW, cm.getRow());
List<Condition> cs = cm.getConditions();
assertEquals(2, cs.size());
@@ -126,7 +126,7 @@ public class ConditionalMutationTest {
assertTrue(cm.equals(cm2));
assertTrue(cm2.equals(cm));
- ConditionalMutation cm3 = new ConditionalMutation("row2".getBytes(Constants.UTF8), c1, c2);
+ ConditionalMutation cm3 = new ConditionalMutation("row2".getBytes(StandardCharsets.UTF_8), c1, c2);
assertFalse(cm.equals(cm3));
cm3 = new ConditionalMutation(ROW, c2, c1);
assertFalse(cm.getConditions().equals(cm3.getConditions()));
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
index 73edd04..ec516d0 100644
--- a/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/RegExFilterTest.java
@@ -17,13 +17,13 @@
package org.apache.accumulo.core.iterators.user;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.TreeMap;
import junit.framework.TestCase;
-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.BatchWriter;
@@ -235,7 +235,7 @@ public class RegExFilterTest extends TestCase {
String multiByteRegex = new String(".*" + "\u6F68" + ".*");
Key k4 = new Key("boo4".getBytes(), "hoo".getBytes(), "20080203".getBytes(), "".getBytes(), 1l);
- Value inVal = new Value(multiByteText.getBytes(Constants.UTF8));
+ Value inVal = new Value(multiByteText.getBytes(StandardCharsets.UTF_8));
tm.put(k4, inVal);
is.clearOptions();
@@ -246,7 +246,7 @@ public class RegExFilterTest extends TestCase {
assertTrue(rei.hasTop());
Value outValue = rei.getTopValue();
- String outVal = new String(outValue.get(), Constants.UTF8);
+ String outVal = new String(outValue.get(), StandardCharsets.UTF_8);
assertTrue(outVal.equals(multiByteText));
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java b/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
index 931ff41..cf91cb0 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/ColumnVisibilityTest.java
@@ -22,9 +22,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
import java.util.Comparator;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.security.ColumnVisibility.Node;
import org.apache.accumulo.core.security.ColumnVisibility.NodeComparator;
import org.apache.accumulo.core.security.ColumnVisibility.NodeType;
@@ -226,11 +226,11 @@ public class ColumnVisibilityTest {
@Test
public void testParseTreesOrdering() {
- byte[] expression = "(b&c&d)|((a|m)&y&z)|(e&f)".getBytes(Constants.UTF8);
+ byte[] expression = "(b&c&d)|((a|m)&y&z)|(e&f)".getBytes(StandardCharsets.UTF_8);
byte[] flattened = new ColumnVisibility(expression).flatten();
// Convert to String for indexOf convenience
- String flat = new String(flattened, Constants.UTF8);
+ String flat = new String(flattened, StandardCharsets.UTF_8);
assertTrue("shortest expressions sort first", flat.indexOf('e') < flat.indexOf('|'));
assertTrue("shortest children sort first", flat.indexOf('b') < flat.indexOf('a'));
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java b/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
index 4f8079e..e2e9d1b 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/CredentialsTest.java
@@ -22,9 +22,10 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.nio.charset.StandardCharsets;
+
import javax.security.auth.DestroyFailedException;
-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.Connector;
@@ -98,7 +99,7 @@ public class CredentialsTest {
assertEquals(abcNullCreds, abcNullCreds);
assertEquals(new Credentials("abc", new NullToken()), abcNullCreds);
// equal, but different token constructors
- assertEquals(new Credentials("abc", new PasswordToken("abc".getBytes(Constants.UTF8))), new Credentials("abc", new PasswordToken("abc")));
+ assertEquals(new Credentials("abc", new PasswordToken("abc".getBytes(StandardCharsets.UTF_8))), new Credentials("abc", new PasswordToken("abc")));
// test not equals
assertFalse(nullNullCreds.equals(abcBlahCreds));
assertFalse(nullNullCreds.equals(abcNullCreds));
@@ -107,7 +108,7 @@ public class CredentialsTest {
@Test
public void testCredentialsSerialization() throws AccumuloSecurityException {
- Credentials creds = new Credentials("a:b-c", new PasswordToken("d-e-f".getBytes(Constants.UTF8)));
+ Credentials creds = new Credentials("a:b-c", new PasswordToken("d-e-f".getBytes(StandardCharsets.UTF_8)));
String serialized = creds.serialize();
Credentials result = Credentials.deserialize(serialized);
assertEquals(creds, result);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/security/VisibilityConstraintTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/security/VisibilityConstraintTest.java b/core/src/test/java/org/apache/accumulo/core/security/VisibilityConstraintTest.java
index de6ca21..fd019c8 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/VisibilityConstraintTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/VisibilityConstraintTest.java
@@ -23,10 +23,10 @@ import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.constraints.Constraint.Environment;
import org.apache.accumulo.core.data.ArrayByteSequence;
import org.apache.accumulo.core.data.Mutation;
@@ -55,7 +55,7 @@ public class VisibilityConstraintTest {
vc = new VisibilityConstraint();
mutation = new Mutation("r");
- ArrayByteSequence bs = new ArrayByteSequence("good".getBytes(Constants.UTF8));
+ ArrayByteSequence bs = new ArrayByteSequence("good".getBytes(StandardCharsets.UTF_8));
AuthorizationContainer ac = createNiceMock(AuthorizationContainer.class);
expect(ac.contains(bs)).andReturn(true);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/security/crypto/BlockedIOStreamTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/security/crypto/BlockedIOStreamTest.java b/core/src/test/java/org/apache/accumulo/core/security/crypto/BlockedIOStreamTest.java
index b344fc3..8ea55a6 100644
--- a/core/src/test/java/org/apache/accumulo/core/security/crypto/BlockedIOStreamTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/security/crypto/BlockedIOStreamTest.java
@@ -22,9 +22,9 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Random;
-import org.apache.accumulo.core.Constants;
import org.junit.Test;
public class BlockedIOStreamTest {
@@ -38,12 +38,12 @@ public class BlockedIOStreamTest {
BlockedOutputStream blockOut = new BlockedOutputStream(baos, blockSize, 1);
String contentString = "My Blocked Content String";
- byte[] content = contentString.getBytes(Constants.UTF8);
+ byte[] content = contentString.getBytes(StandardCharsets.UTF_8);
blockOut.write(content);
blockOut.flush();
String contentString2 = "My Other Blocked Content String";
- byte[] content2 = contentString2.getBytes(Constants.UTF8);
+ byte[] content2 = contentString2.getBytes(StandardCharsets.UTF_8);
blockOut.write(content2);
blockOut.flush();
@@ -56,12 +56,12 @@ public class BlockedIOStreamTest {
DataInputStream dIn = new DataInputStream(blockIn);
dIn.readFully(content, 0, content.length);
- String readContentString = new String(content, Constants.UTF8);
+ String readContentString = new String(content, StandardCharsets.UTF_8);
assertEquals(contentString, readContentString);
dIn.readFully(content2, 0, content2.length);
- String readContentString2 = new String(content2, Constants.UTF8);
+ String readContentString2 = new String(content2, StandardCharsets.UTF_8);
assertEquals(contentString2, readContentString2);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/util/format/DeleterFormatterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/format/DeleterFormatterTest.java b/core/src/test/java/org/apache/accumulo/core/util/format/DeleterFormatterTest.java
index 36def05..9223166 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/format/DeleterFormatterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/format/DeleterFormatterTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.accumulo.core.util.format;
-import static org.apache.accumulo.core.Constants.UTF8;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createNiceMock;
@@ -31,6 +30,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
@@ -68,7 +68,7 @@ public class DeleterFormatterTest {
}
public void set(String in) {
- bais = new ByteArrayInputStream(in.getBytes(UTF8));
+ bais = new ByteArrayInputStream(in.getBytes(StandardCharsets.UTF_8));
}
};
@@ -94,7 +94,7 @@ public class DeleterFormatterTest {
replay(writer, exceptionWriter, shellState);
data = new TreeMap<Key,Value>();
- data.put(new Key("r", "cf", "cq"), new Value("value".getBytes(UTF8)));
+ data.put(new Key("r", "cf", "cq"), new Value("value".getBytes(StandardCharsets.UTF_8)));
}
@Test
@@ -116,7 +116,7 @@ public class DeleterFormatterTest {
@Test
public void testNo() throws IOException {
input.set("no\n");
- data.put(new Key("z"), new Value("v2".getBytes(UTF8)));
+ data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8)));
formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false);
assertTrue(formatter.hasNext());
@@ -130,7 +130,7 @@ public class DeleterFormatterTest {
@Test
public void testNoConfirmation() throws IOException {
input.set("");
- data.put(new Key("z"), new Value("v2".getBytes(UTF8)));
+ data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8)));
formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false);
assertTrue(formatter.hasNext());
@@ -144,7 +144,7 @@ public class DeleterFormatterTest {
@Test
public void testYes() throws IOException {
input.set("y\nyes\n");
- data.put(new Key("z"), new Value("v2".getBytes(UTF8)));
+ data.put(new Key("z"), new Value("v2".getBytes(StandardCharsets.UTF_8)));
formatter = new DeleterFormatter(writer, data.entrySet(), true, shellState, false);
assertTrue(formatter.hasNext());
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatterTest.java b/core/src/test/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatterTest.java
index 1707dda..c4a7107 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatterTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/format/ShardedTableDistributionFormatterTest.java
@@ -19,10 +19,10 @@ package org.apache.accumulo.core.util.format;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.junit.Before;
@@ -52,9 +52,9 @@ public class ShardedTableDistributionFormatterTest {
@Test
public void testAggregate() {
- data.put(new Key("t", "~tab", "loc"), new Value("srv1".getBytes(Constants.UTF8)));
- data.put(new Key("t;19700101", "~tab", "loc", 0), new Value("srv1".getBytes(Constants.UTF8)));
- data.put(new Key("t;19700101", "~tab", "loc", 1), new Value("srv2".getBytes(Constants.UTF8)));
+ data.put(new Key("t", "~tab", "loc"), new Value("srv1".getBytes(StandardCharsets.UTF_8)));
+ data.put(new Key("t;19700101", "~tab", "loc", 0), new Value("srv1".getBytes(StandardCharsets.UTF_8)));
+ data.put(new Key("t;19700101", "~tab", "loc", 1), new Value("srv2".getBytes(StandardCharsets.UTF_8)));
formatter.initialize(data.entrySet(), false);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/core/src/test/java/org/apache/accumulo/core/util/shell/ShellUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellUtilTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellUtilTest.java
index fe7c1db..a5fd179 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellUtilTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellUtilTest.java
@@ -21,9 +21,9 @@ import static org.junit.Assert.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.List;
-import org.apache.accumulo.core.Constants;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.io.Text;
@@ -55,7 +55,7 @@ public class ShellUtilTest {
FileUtils.writeStringToFile(testFile, FILEDATA);
List<Text> output = ShellUtil.scanFile(testFile.getAbsolutePath(), true);
assertEquals(
- ImmutableList.of(new Text(Base64.decodeBase64("line1".getBytes(Constants.UTF8))), new Text(Base64.decodeBase64("line2".getBytes(Constants.UTF8)))),
+ ImmutableList.of(new Text(Base64.decodeBase64("line1".getBytes(StandardCharsets.UTF_8))), new Text(Base64.decodeBase64("line2".getBytes(StandardCharsets.UTF_8)))),
output);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index be29dbb..e65b956 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.proxy;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -34,7 +35,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-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.BatchScanner;
@@ -194,7 +194,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
}
protected Connector getConnector(ByteBuffer login) throws Exception {
- String[] pair = new String(login.array(), login.position(), login.remaining(), Constants.UTF8).split(",", 2);
+ String[] pair = new String(login.array(), login.position(), login.remaining(), StandardCharsets.UTF_8).split(",", 2);
if (instance.getInstanceID().equals(pair[0])) {
Credentials creds = Credentials.deserialize(pair[1]);
return instance.getConnector(creds.getPrincipal(), creds.getToken());
@@ -1489,7 +1489,7 @@ public class ProxyServer implements AccumuloProxy.Iface {
public ByteBuffer login(String principal, Map<String,String> loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
try {
AuthenticationToken token = getToken(principal, loginProperties);
- ByteBuffer login = ByteBuffer.wrap((instance.getInstanceID() + "," + new Credentials(principal, token).serialize()).getBytes(Constants.UTF8));
+ ByteBuffer login = ByteBuffer.wrap((instance.getInstanceID() + "," + new Credentials(principal, token).serialize()).getBytes(StandardCharsets.UTF_8));
getConnector(login); // check to make sure user exists
return login;
} catch (AccumuloSecurityException e) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
index 4377126..5f84c2f 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.proxy;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
@@ -24,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.iterators.user.RegExFilter;
import org.apache.accumulo.proxy.thrift.AccumuloProxy;
@@ -74,7 +74,7 @@ public class TestProxyClient {
System.out.println("Creating user: ");
if (!tpc.proxy().listLocalUsers(login).contains("testuser")) {
- tpc.proxy().createLocalUser(login, "testuser", ByteBuffer.wrap("testpass".getBytes(Constants.UTF8)));
+ tpc.proxy().createLocalUser(login, "testuser", ByteBuffer.wrap("testpass".getBytes(StandardCharsets.UTF_8)));
}
System.out.println("UserList: " + tpc.proxy().listLocalUsers(login));
@@ -100,9 +100,9 @@ public class TestProxyClient {
Map<ByteBuffer,List<ColumnUpdate>> mutations = new HashMap<ByteBuffer,List<ColumnUpdate>>();
for (int i = 0; i < maxInserts; i++) {
String result = String.format(format, i);
- ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(Constants.UTF8)), ByteBuffer.wrap(("cq" + i).getBytes(Constants.UTF8)));
+ ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(("cq" + i).getBytes(StandardCharsets.UTF_8)));
update.setValue(Util.randStringBuffer(10));
- mutations.put(ByteBuffer.wrap(result.getBytes(Constants.UTF8)), Collections.singletonList(update));
+ mutations.put(ByteBuffer.wrap(result.getBytes(StandardCharsets.UTF_8)), Collections.singletonList(update));
if (i % 1000 == 0) {
tpc.proxy().updateAndFlush(login, testTable, mutations);
@@ -126,10 +126,10 @@ public class TestProxyClient {
for (int i = 0; i < maxInserts; i++) {
String result = String.format(format, i);
Key pkey = new Key();
- pkey.setRow(result.getBytes(Constants.UTF8));
- ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(Constants.UTF8)), ByteBuffer.wrap(("cq" + i).getBytes(Constants.UTF8)));
+ pkey.setRow(result.getBytes(StandardCharsets.UTF_8));
+ ColumnUpdate update = new ColumnUpdate(ByteBuffer.wrap(("cf" + i).getBytes(StandardCharsets.UTF_8)), ByteBuffer.wrap(("cq" + i).getBytes(StandardCharsets.UTF_8)));
update.setValue(Util.randStringBuffer(10));
- mutations.put(ByteBuffer.wrap(result.getBytes(Constants.UTF8)), Collections.singletonList(update));
+ mutations.put(ByteBuffer.wrap(result.getBytes(StandardCharsets.UTF_8)), Collections.singletonList(update));
tpc.proxy().update(writer, mutations);
mutations.clear();
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
----------------------------------------------------------------------
diff --git a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
index 9f9c836..94b0709 100644
--- a/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
+++ b/proxy/src/main/java/org/apache/accumulo/proxy/Util.java
@@ -18,9 +18,9 @@ package org.apache.accumulo.proxy;
import java.math.BigInteger;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.Random;
-import org.apache.accumulo.core.Constants;
import org.apache.accumulo.proxy.thrift.IteratorSetting;
import org.apache.accumulo.proxy.thrift.Key;
@@ -33,7 +33,7 @@ public class Util {
}
public static ByteBuffer randStringBuffer(int numbytes) {
- return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes(Constants.UTF8));
+ return ByteBuffer.wrap(new BigInteger(numbytes * 5, random).toString(32).getBytes(StandardCharsets.UTF_8));
}
public static IteratorSetting iteratorSetting2ProxyIteratorSetting(org.apache.accumulo.core.client.IteratorSetting is) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
index 0cf6b8f..29ed2b7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -176,7 +177,7 @@ public class Accumulo {
try {
byte[] buffer = new byte[10];
int bytes = is.read(buffer);
- String setting = new String(buffer, 0, bytes, Constants.UTF8);
+ String setting = new String(buffer, 0, bytes, StandardCharsets.UTF_8);
setting = setting.trim();
if (bytes > 0 && Integer.parseInt(setting) > 10) {
log.warn("System swappiness setting is greater than ten (" + setting + ") which can cause time-sensitive operations to be delayed. "
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java b/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
index f59ec39..d2ad02b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/HdfsZooInstance.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.server.client;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@@ -91,13 +92,13 @@ public class HdfsZooInstance implements Instance {
byte[] loc = zooCache.get(zRootLocPath);
- opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");
+ opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc, StandardCharsets.UTF_8)) + " in %DURATION%");
if (loc == null) {
return null;
}
- return new String(loc, Constants.UTF8).split("\\|")[0];
+ return new String(loc, StandardCharsets.UTF_8).split("\\|")[0];
}
@Override
@@ -109,13 +110,13 @@ public class HdfsZooInstance implements Instance {
byte[] loc = ZooLock.getLockData(zooCache, masterLocPath, null);
- opTimer.stop("Found master at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");
+ opTimer.stop("Found master at " + (loc == null ? null : new String(loc, StandardCharsets.UTF_8)) + " in %DURATION%");
if (loc == null) {
return Collections.emptyList();
}
- return Collections.singletonList(new String(loc, Constants.UTF8));
+ return Collections.singletonList(new String(loc, StandardCharsets.UTF_8));
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
index 99532ca..331d8ad 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.conf;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -76,7 +77,7 @@ public class NamespaceConfiguration extends AccumuloConfiguration {
byte[] v = zc.get(zPath);
String value = null;
if (v != null)
- value = new String(v, Constants.UTF8);
+ value = new String(v, StandardCharsets.UTF_8);
return value;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
index c134e31..39a2699 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.conf;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -130,7 +131,7 @@ public class TableConfiguration extends AccumuloConfiguration {
byte[] v = zc.get(zPath);
String value = null;
if (v != null)
- value = new String(v, Constants.UTF8);
+ value = new String(v, StandardCharsets.UTF_8);
return value;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
index 0c03aac..b13e66b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
@@ -17,6 +17,7 @@
package org.apache.accumulo.server.conf;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -124,7 +125,7 @@ public class ZooConfiguration extends AccumuloConfiguration {
byte[] v = propCache.get(zPath);
String value = null;
if (v != null)
- value = new String(v, Constants.UTF8);
+ value = new String(v, StandardCharsets.UTF_8);
return value;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/f8ca8d34/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
index 807e821..ecb0db8 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/constraints/MetadataConstraints.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.server.constraints;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -195,7 +196,7 @@ public class MetadataConstraints implements Constraint {
HashSet<Text> dataFiles = new HashSet<Text>();
HashSet<Text> loadedFiles = new HashSet<Text>();
- String tidString = new String(columnUpdate.getValue(), Constants.UTF8);
+ String tidString = new String(columnUpdate.getValue(), StandardCharsets.UTF_8);
int otherTidCount = 0;
for (ColumnUpdate update : mutation.getUpdates()) {
@@ -208,7 +209,7 @@ public class MetadataConstraints implements Constraint {
} else if (new Text(update.getColumnFamily()).equals(TabletsSection.BulkFileColumnFamily.NAME)) {
loadedFiles.add(new Text(update.getColumnQualifier()));
- if (!new String(update.getValue(), Constants.UTF8).equals(tidString)) {
+ if (!new String(update.getValue(), StandardCharsets.UTF_8).equals(tidString)) {
otherTidCount++;
}
}
@@ -252,7 +253,7 @@ public class MetadataConstraints implements Constraint {
}
boolean lockHeld = false;
- String lockId = new String(columnUpdate.getValue(), Constants.UTF8);
+ String lockId = new String(columnUpdate.getValue(), StandardCharsets.UTF_8);
try {
lockHeld = ZooLock.isLockHeld(zooCache, new ZooUtil.LockID(zooRoot, lockId));
@@ -269,10 +270,10 @@ public class MetadataConstraints implements Constraint {
}
if (violations != null) {
- log.debug("violating metadata mutation : " + new String(mutation.getRow(), Constants.UTF8));
+ log.debug("violating metadata mutation : " + new String(mutation.getRow(), StandardCharsets.UTF_8));
for (ColumnUpdate update : mutation.getUpdates()) {
- log.debug(" update: " + new String(update.getColumnFamily(), Constants.UTF8) + ":" + new String(update.getColumnQualifier(), Constants.UTF8) + " value "
- + (update.isDeleted() ? "[delete]" : new String(update.getValue(), Constants.UTF8)));
+ log.debug(" update: " + new String(update.getColumnFamily(), StandardCharsets.UTF_8) + ":" + new String(update.getColumnQualifier(), StandardCharsets.UTF_8) + " value "
+ + (update.isDeleted() ? "[delete]" : new String(update.getValue(), StandardCharsets.UTF_8)));
}
}