ACCUMULO-1545 Replace UTF8 constant with built-in one
diff --git a/src/main/java/org/apache/accumulo/proxy/ProxyServer.java b/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
index be29dbb..e65b956 100644
--- a/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
+++ b/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.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 @@
}
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 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) {
diff --git a/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java b/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
index 4377126..5f84c2f 100644
--- a/src/main/java/org/apache/accumulo/proxy/TestProxyClient.java
+++ b/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.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 @@
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 @@
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 @@
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();
}
diff --git a/src/main/java/org/apache/accumulo/proxy/Util.java b/src/main/java/org/apache/accumulo/proxy/Util.java
index 9f9c836..94b0709 100644
--- a/src/main/java/org/apache/accumulo/proxy/Util.java
+++ b/src/main/java/org/apache/accumulo/proxy/Util.java
@@ -18,9 +18,9 @@
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 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) {