kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject kudu git commit: java: fix error-prone DefaultCharset[1] issues
Date Thu, 03 May 2018 16:51:00 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 610b1aefb -> 96fa80503


java: fix error-prone DefaultCharset[1] issues

This should be a non-functional change on all systems where UTF8 is the
default character set. It may fix issues on other systems which are
exceedingly rare these days.

[1] https://github.com/google/error-prone/blob/master/docs/bugpattern/DefaultCharset.md

Change-Id: Ic92985b5d9466c8629475f3645c872914e3f73a1
Reviewed-on: http://gerrit.cloudera.org:8080/10197
Reviewed-by: Grant Henke <granthenke@apache.org>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/96fa8050
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/96fa8050
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/96fa8050

Branch: refs/heads/master
Commit: 96fa805030f859fd0d8d25243191534222163eb5
Parents: 610b1ae
Author: Todd Lipcon <todd@apache.org>
Authored: Wed Apr 25 11:43:20 2018 -0700
Committer: Grant Henke <granthenke@apache.org>
Committed: Thu May 3 16:49:20 2018 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/mapreduce/tools/ITImportCsv.java  |  3 +--
 .../java/org/apache/kudu/client/AsyncKuduScanner.java |  3 ++-
 .../org/apache/kudu/client/ColumnRangePredicate.java  |  6 ++++--
 .../java/org/apache/kudu/client/ProtobufHelper.java   |  7 ++++---
 .../java/org/apache/kudu/client/RemoteTablet.java     |  4 +++-
 .../java/org/apache/kudu/client/MiniKuduCluster.java  |  5 ++++-
 .../org/apache/kudu/client/TestAsyncKuduClient.java   |  6 +++---
 .../java/org/apache/kudu/client/TestKeyEncoding.java  | 14 +++++++-------
 .../java/org/apache/kudu/client/TestKuduClient.java   |  3 ++-
 .../org/apache/kudu/client/TestKuduPredicate.java     | 12 +++++++++---
 .../java/org/apache/kudu/client/TestRowResult.java    | 13 +++++++------
 .../java/org/apache/kudu/client/TestTestUtils.java    |  3 ++-
 .../flume/sink/AvroKuduOperationsProducerTest.java    |  4 ++--
 .../flume/sink/KeyedKuduOperationsProducerTest.java   |  9 +++++----
 .../java/org/apache/kudu/flume/sink/KuduSinkTest.java |  7 ++++---
 .../flume/sink/RegexpKuduOperationsProducerTest.java  |  7 ++++---
 .../org/apache/kudu/mapreduce/ITOutputFormatJob.java  |  2 +-
 .../java/org/apache/kudu/mapreduce/TestJarFinder.java |  7 ++++---
 18 files changed, 68 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client-tools/src/test/java/org/apache/kudu/mapreduce/tools/ITImportCsv.java
----------------------------------------------------------------------
diff --git a/java/kudu-client-tools/src/test/java/org/apache/kudu/mapreduce/tools/ITImportCsv.java
b/java/kudu-client-tools/src/test/java/org/apache/kudu/mapreduce/tools/ITImportCsv.java
index 43c0f37..45d50d6 100644
--- a/java/kudu-client-tools/src/test/java/org/apache/kudu/mapreduce/tools/ITImportCsv.java
+++ b/java/kudu-client-tools/src/test/java/org/apache/kudu/mapreduce/tools/ITImportCsv.java
@@ -17,6 +17,7 @@
 
 package org.apache.kudu.mapreduce.tools;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -42,8 +43,6 @@ import org.apache.kudu.client.CreateTableOptions;
 import org.apache.kudu.mapreduce.CommandLineParser;
 import org.apache.kudu.mapreduce.HadoopTestingUtility;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-
 public class ITImportCsv extends BaseKuduTest {
 
   private static final String TABLE_NAME =

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
index ceae708..0d13fa6 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduScanner.java
@@ -27,6 +27,7 @@
 package org.apache.kudu.client;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.tserver.Tserver.NewScanRequestPB;
 import static org.apache.kudu.tserver.Tserver.ScanRequestPB;
 import static org.apache.kudu.tserver.Tserver.ScanResponsePB;
@@ -620,7 +621,7 @@ public final class AsyncKuduScanner {
               tablet);
         }
         invalidate();
-        scannerId = "client debug closed".getBytes();   // Make debugging easier.
+        scannerId = "client debug closed".getBytes(UTF_8);   // Make debugging easier.
         return response == null ? null : response.data;
       }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
b/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
index 6a9fbef..697501d 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ColumnRangePredicate.java
@@ -17,6 +17,8 @@
 
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -184,7 +186,7 @@ public class ColumnRangePredicate {
    */
   public void setLowerBound(String lowerBound) {
     checkColumn(Type.STRING);
-    setLowerBoundInternal(lowerBound.getBytes());
+    setLowerBoundInternal(lowerBound.getBytes(UTF_8));
   }
 
   /**
@@ -281,7 +283,7 @@ public class ColumnRangePredicate {
    */
   public void setUpperBound(String upperBound) {
     checkColumn(Type.STRING);
-    setUpperBoundInternal(upperBound.getBytes());
+    setUpperBoundInternal(upperBound.getBytes(UTF_8));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
index b76194f..d49fa8f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/ProtobufHelper.java
@@ -17,13 +17,14 @@
 
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.net.HostAndPort;
@@ -232,7 +233,7 @@ public class ProtobufHelper {
       case UNIXTIME_MICROS:
         return Bytes.fromLong((Long) value);
       case STRING:
-        return ((String) value).getBytes(Charsets.UTF_8);
+        return ((String) value).getBytes(UTF_8);
       case BINARY:
         return (byte[]) value;
       case FLOAT:
@@ -301,7 +302,7 @@ public class ProtobufHelper {
     } else if (value instanceof Long) {
       bytes = Bytes.fromLong((Long) value);
     } else if (value instanceof String) {
-      bytes = ((String) value).getBytes(Charsets.UTF_8);
+      bytes = ((String) value).getBytes(UTF_8);
     } else if (value instanceof byte[]) {
       bytes = (byte[]) value;
     } else if (value instanceof ByteBuffer) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
index bb2ca27..a8db63d 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RemoteTablet.java
@@ -17,6 +17,8 @@
 
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -234,7 +236,7 @@ class RemoteTablet implements Comparable<RemoteTablet> {
   }
 
   byte[] getTabletIdAsBytes() {
-    return tabletId.getBytes();
+    return tabletId.getBytes(UTF_8);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
index d0b1852..2791b25 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
@@ -14,6 +14,8 @@
 
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.BufferedReader;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -462,7 +464,8 @@ public class MiniKuduCluster implements AutoCloseable {
     public void run() {
       try {
         String line;
-        BufferedReader in = new BufferedReader(new InputStreamReader(is));
+        BufferedReader in = new BufferedReader(
+            new InputStreamReader(is, UTF_8));
         while ((line = in.readLine()) != null) {
           LOG.info(line);
         }

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
index 2ccf431..ae3c04f 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduClient.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
@@ -25,7 +26,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Stopwatch;
 import com.google.protobuf.ByteString;
 import com.stumbleupon.async.Deferred;
@@ -140,8 +140,8 @@ public class TestAsyncKuduClient extends BaseKuduTest {
     Master.TabletLocationsPB.Builder tabletPb = Master.TabletLocationsPB.newBuilder();
     for (int i = 0; i < 3; i++) {
       Common.PartitionPB.Builder partition = Common.PartitionPB.newBuilder();
-      partition.setPartitionKeyStart(ByteString.copyFrom("a" + i, Charsets.UTF_8.name()));
-      partition.setPartitionKeyEnd(ByteString.copyFrom("b" + i, Charsets.UTF_8.name()));
+      partition.setPartitionKeyStart(ByteString.copyFrom("a" + i, UTF_8.name()));
+      partition.setPartitionKeyEnd(ByteString.copyFrom("b" + i, UTF_8.name()));
       tabletPb.setPartition(partition);
       tabletPb.setTabletId(ByteString.copyFromUtf8("some id " + i));
       tabletPb.addReplicas(TestUtils.getFakeTabletReplicaPB(

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
index 6122190..88f3e9b 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKeyEncoding.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -23,7 +24,6 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 import org.junit.Test;
 
@@ -58,7 +58,7 @@ public class TestKeyEncoding extends BaseKuduTest {
   }
 
   private static void assertBytesEquals(byte[] actual, String expected) {
-    assertBytesEquals(actual, expected.getBytes(Charsets.UTF_8));
+    assertBytesEquals(actual, expected.getBytes(UTF_8));
   }
 
   /**
@@ -186,7 +186,7 @@ public class TestKeyEncoding extends BaseKuduTest {
     rowA.addDecimal("decimal64", BigDecimal.valueOf(6));
     rowA.addDecimal("decimal128", BigDecimal.valueOf(7));
     rowA.addString("string", "");
-    rowA.addBinary("binary", "".getBytes(Charsets.UTF_8));
+    rowA.addBinary("binary", "".getBytes(UTF_8));
 
     byte[] rowAEncoded = rowA.encodePrimaryKey();
     assertBytesEquals(rowAEncoded,
@@ -214,7 +214,7 @@ public class TestKeyEncoding extends BaseKuduTest {
     rowB.addDecimal("decimal64", BigDecimal.valueOf(6));
     rowB.addDecimal("decimal128", BigDecimal.valueOf(7));
     rowB.addString("string", "abc\1\0def");
-    rowB.addBinary("binary", "\0\1binary".getBytes(Charsets.UTF_8));
+    rowB.addBinary("binary", "\0\1binary".getBytes(UTF_8));
 
     byte[] rowBEncoded = rowB.encodePrimaryKey();
     assertBytesEquals(rowB.encodePrimaryKey(),
@@ -241,7 +241,7 @@ public class TestKeyEncoding extends BaseKuduTest {
     rowC.addDecimal("decimal64", BigDecimal.valueOf(6));
     rowC.addDecimal("decimal128", BigDecimal.valueOf(7));
     rowC.addString("string", "abc\n123");
-    rowC.addBinary("binary", "\0\1\2\3\4\5".getBytes(Charsets.UTF_8));
+    rowC.addBinary("binary", "\0\1\2\3\4\5".getBytes(UTF_8));
 
     byte[] rowCEncoded = rowC.encodePrimaryKey();
     assertBytesEquals(rowCEncoded,
@@ -268,7 +268,7 @@ public class TestKeyEncoding extends BaseKuduTest {
     rowD.addDecimal("decimal64", BigDecimal.valueOf(-6));
     rowD.addDecimal("decimal128", BigDecimal.valueOf(-7));
     rowD.addString("string", "\0abc\n\1\1\0 123\1\0");
-    rowD.addBinary("binary", "\0\1\2\3\4\5\0".getBytes(Charsets.UTF_8));
+    rowD.addBinary("binary", "\0\1\2\3\4\5\0".getBytes(UTF_8));
 
     byte[] rowDEncoded = rowD.encodePrimaryKey();
     assertBytesEquals(rowDEncoded,
@@ -383,7 +383,7 @@ public class TestKeyEncoding extends BaseKuduTest {
     row.addInt(2, 3);
     row.addLong(3, 4l);
     row.addString(4, "foo");
-    row.addBinary(5, "bar".getBytes(Charsets.UTF_8));
+    row.addBinary(5, "bar".getBytes(UTF_8));
     row.addLong(6, 6l);
     row.addDecimal(7, BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL32));
     row.addDecimal(8, BigDecimal.valueOf(DecimalUtil.MAX_UNSCALED_DECIMAL64));

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
index 56a4da7..5b3e210 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduClient.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER_EQUAL;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.LESS;
@@ -372,7 +373,7 @@ public class TestKuduClient extends BaseKuduTest {
     for (int i = 0; i < 100; i++) {
       Insert insert = table.newInsert();
       PartialRow row = insert.getRow();
-      row.addBinary("key", String.format("key_%02d", i).getBytes());
+      row.addBinary("key", String.format("key_%02d", i).getBytes(UTF_8));
       row.addString("c1", "✁✂✃✄✆");
       row.addDouble("c2", i);
       if (i % 2 == 1) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
index 1caf626..0cb2333 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestKuduPredicate.java
@@ -17,6 +17,7 @@
 
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.EQUAL;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER;
 import static org.apache.kudu.client.KuduPredicate.ComparisonOp.GREATER_EQUAL;
@@ -929,9 +930,14 @@ public class TestKuduPredicate {
                                 new byte[] { 0, 1, 2, 3, 4, 5, 6 },
                                 new byte[] { 10 }));
 
-    testMerge(KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of("a".getBytes(),
"b".getBytes(), "c".getBytes(), "d".getBytes())),
-              KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of("b".getBytes(),
"d".getBytes(), "e".getBytes())),
-              KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of("b".getBytes(),
"d".getBytes())));
+    byte[] bA = "a".getBytes(UTF_8);
+    byte[] bB = "b".getBytes(UTF_8);
+    byte[] bC = "c".getBytes(UTF_8);
+    byte[] bD = "d".getBytes(UTF_8);
+    byte[] bE = "e".getBytes(UTF_8);
+    testMerge(KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bA, bB, bC, bD)),
+              KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bB, bD, bE)),
+              KuduPredicate.newInListPredicate(binaryCol, ImmutableList.of(bB, bD)));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
index 5196eda..4207bf6 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRowResult.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
@@ -56,8 +57,8 @@ public class TestRowResult extends BaseKuduTest {
     row.addFloat(5, 5.6f);
     row.addDouble(6, 7.8);
     row.addString(7, "string-value");
-    row.addBinary(8, "binary-array".getBytes());
-    ByteBuffer bb = ByteBuffer.wrap("binary-bytebuffer".getBytes());
+    row.addBinary(8, "binary-array".getBytes(UTF_8));
+    ByteBuffer bb = ByteBuffer.wrap("binary-bytebuffer".getBytes(UTF_8));
     bb.position(7); // We're only inserting the bytebuffer part of the original array.
     row.addBinary(9, bb);
     row.setNull(10);
@@ -97,17 +98,17 @@ public class TestRowResult extends BaseKuduTest {
       assertEquals("string-value", rr.getString(7));
       assertEquals("string-value", rr.getString(allTypesSchema.getColumnByIndex(7).getName()));
 
-      assertArrayEquals("binary-array".getBytes(), rr.getBinaryCopy(8));
-      assertArrayEquals("binary-array".getBytes(),
+      assertArrayEquals("binary-array".getBytes(UTF_8), rr.getBinaryCopy(8));
+      assertArrayEquals("binary-array".getBytes(UTF_8),
           rr.getBinaryCopy(allTypesSchema.getColumnByIndex(8).getName()));
 
       ByteBuffer buffer = rr.getBinary(8);
       assertEquals(buffer, rr.getBinary(allTypesSchema.getColumnByIndex(8).getName()));
       byte[] binaryValue = new byte[buffer.remaining()];
       buffer.get(binaryValue);
-      assertArrayEquals("binary-array".getBytes(), binaryValue);
+      assertArrayEquals("binary-array".getBytes(UTF_8), binaryValue);
 
-      assertArrayEquals("bytebuffer".getBytes(), rr.getBinaryCopy(9));
+      assertArrayEquals("bytebuffer".getBytes(UTF_8), rr.getBinaryCopy(9));
 
       assertEquals(true, rr.isNull(10));
       assertEquals(true, rr.isNull(allTypesSchema.getColumnByIndex(10).getName()));

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-client/src/test/java/org/apache/kudu/client/TestTestUtils.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTestUtils.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTestUtils.java
index ae164fe..ce55921 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestTestUtils.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestTestUtils.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.client;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -90,7 +91,7 @@ public class TestTestUtils {
     public void run() {
       BufferedReader in = null;
       try {
-        in = new BufferedReader(new InputStreamReader(is));
+        in = new BufferedReader(new InputStreamReader(is, UTF_8));
         while (in.readLine() != null) {
           counter.incrementAndGet();
         }

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducerTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducerTest.java
b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducerTest.java
index 21812f8..26c7647 100644
--- a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducerTest.java
+++ b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/AvroKuduOperationsProducerTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.kudu.flume.sink;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.flume.sink.AvroKuduOperationsProducer.SCHEMA_LITERAL_HEADER;
 import static org.apache.kudu.flume.sink.AvroKuduOperationsProducer.SCHEMA_PROP;
 import static org.apache.kudu.flume.sink.AvroKuduOperationsProducer.SCHEMA_URL_HEADER;
@@ -38,7 +39,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
@@ -78,7 +78,7 @@ public class AvroKuduOperationsProducerTest extends BaseKuduTest {
   @BeforeClass
   public static void setupAvroSchemaBeforeClass() {
     try {
-      schemaLiteral = Files.toString(new File(schemaPath), Charsets.UTF_8);
+      schemaLiteral = Files.toString(new File(schemaPath), UTF_8);
     } catch (IOException e) {
       throw new FlumeException("Unable to read schema file!", e);
     }

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KeyedKuduOperationsProducerTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KeyedKuduOperationsProducerTest.java
b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KeyedKuduOperationsProducerTest.java
index 6b62528..842f216 100644
--- a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KeyedKuduOperationsProducerTest.java
+++ b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KeyedKuduOperationsProducerTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.kudu.flume.sink;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.MASTER_ADDRESSES;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.PRODUCER;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.PRODUCER_PREFIX;
@@ -32,7 +33,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import org.apache.flume.Channel;
@@ -126,7 +126,7 @@ public class KeyedKuduOperationsProducerTest extends BaseKuduTest {
 
     int numRows = 3;
     for (int i = 0; i < numRows; i++) {
-      Event e = EventBuilder.withBody(String.format("payload body %s", i), Charsets.UTF_8);
+      Event e = EventBuilder.withBody(String.format("payload body %s", i), UTF_8);
       e.setHeaders(ImmutableMap.of(KEY_COLUMN_DEFAULT, String.format("key %s", i)));
       channel.put(e);
     }
@@ -147,7 +147,7 @@ public class KeyedKuduOperationsProducerTest extends BaseKuduTest {
     Transaction utx = channel.getTransaction();
     utx.begin();
 
-    Event dup = EventBuilder.withBody("payload body upserted".getBytes());
+    Event dup = EventBuilder.withBody("payload body upserted".getBytes(UTF_8));
     dup.setHeaders(ImmutableMap.of("key", String.format("key %s", 0)));
     channel.put(dup);
 
@@ -185,7 +185,8 @@ public class KeyedKuduOperationsProducerTest extends BaseKuduTest {
     tx.begin();
 
     for (int i = 0; i < eventCount; i++) {
-      Event e = EventBuilder.withBody(String.format("payload body %s", i).getBytes());
+      Event e = EventBuilder.withBody(String.format("payload body %s", i)
+          .getBytes(UTF_8));
       e.setHeaders(ImmutableMap.of("key", String.format("key %s", i)));
       channel.put(e);
     }

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KuduSinkTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KuduSinkTest.java
b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KuduSinkTest.java
index 937415b..46f23f8 100644
--- a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KuduSinkTest.java
+++ b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/KuduSinkTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.kudu.flume.sink;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -26,7 +27,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.ImmutableList;
 import org.apache.flume.Channel;
 import org.apache.flume.Context;
@@ -150,7 +150,7 @@ public class KuduSinkTest extends BaseKuduTest {
     tx.begin();
 
     for (int i = 0; i < 2; i++) {
-      Event e = EventBuilder.withBody("key-0", Charsets.UTF_8); // Duplicate keys.
+      Event e = EventBuilder.withBody("key-0", UTF_8); // Duplicate keys.
       channel.put(e);
     }
 
@@ -199,7 +199,8 @@ public class KuduSinkTest extends BaseKuduTest {
     tx.begin();
 
     for (int i = 0; i < eventCount; i++) {
-      Event e = EventBuilder.withBody(String.format("payload body %s", i).getBytes());
+      Event e = EventBuilder.withBody(String.format("payload body %s", i)
+          .getBytes(UTF_8));
       channel.put(e);
     }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/RegexpKuduOperationsProducerTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/RegexpKuduOperationsProducerTest.java
b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/RegexpKuduOperationsProducerTest.java
index ece55f7..0ebec8b 100644
--- a/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/RegexpKuduOperationsProducerTest.java
+++ b/java/kudu-flume-sink/src/test/java/org/apache/kudu/flume/sink/RegexpKuduOperationsProducerTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.kudu.flume.sink;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.MASTER_ADDRESSES;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.PRODUCER;
 import static org.apache.kudu.flume.sink.KuduSinkConfigurationConstants.PRODUCER_PREFIX;
@@ -134,7 +135,7 @@ public class RegexpKuduOperationsProducerTest extends BaseKuduTest {
         String row = String.format(baseRow, i, j);
         payload.append(row);
       }
-      Event e = EventBuilder.withBody(payload.toString().getBytes());
+      Event e = EventBuilder.withBody(payload.toString().getBytes(UTF_8));
       channel.put(e);
     }
 
@@ -148,7 +149,7 @@ public class RegexpKuduOperationsProducerTest extends BaseKuduTest {
               "string,false,%1$d.%1$d,%1$d.%1$d,%1$d.%1$d,%1$d|", 1, 0, j);
           upserts.append(row);
         }
-        Event e = EventBuilder.withBody(upserts.toString().getBytes());
+        Event e = EventBuilder.withBody(upserts.toString().getBytes(UTF_8));
         channel.put(e);
       }
 
@@ -157,7 +158,7 @@ public class RegexpKuduOperationsProducerTest extends BaseKuduTest {
       String emptyString = "";
       String[] testCases = {mismatchInInt, emptyString};
       for (String testCase : testCases) {
-        Event e = EventBuilder.withBody(testCase.getBytes());
+        Event e = EventBuilder.withBody(testCase.getBytes(UTF_8));
         channel.put(e);
       }
     }

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/ITOutputFormatJob.java
----------------------------------------------------------------------
diff --git a/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/ITOutputFormatJob.java
b/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/ITOutputFormatJob.java
index 068219d..85c5dc4 100644
--- a/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/ITOutputFormatJob.java
+++ b/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/ITOutputFormatJob.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.kudu.mapreduce;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -42,7 +43,6 @@ import org.apache.kudu.client.KuduTable;
 import org.apache.kudu.client.Operation;
 import org.apache.kudu.client.PartialRow;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
 
 public class ITOutputFormatJob extends BaseKuduTest {
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/96fa8050/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/TestJarFinder.java
----------------------------------------------------------------------
diff --git a/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/TestJarFinder.java
b/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/TestJarFinder.java
index 5f640e0..73401c1 100644
--- a/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/TestJarFinder.java
+++ b/java/kudu-mapreduce/src/test/java/org/apache/kudu/mapreduce/TestJarFinder.java
@@ -16,11 +16,12 @@
 // under the License.
 package org.apache.kudu.mapreduce;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.FileWriter;
 import java.io.OutputStream;
 import java.io.Writer;
 import java.nio.file.Files;
@@ -82,7 +83,7 @@ public class TestJarFinder {
     os.close();
 
     File propsFile = new File(dir, "props.properties");
-    Writer writer = new FileWriter(propsFile);
+    Writer writer = Files.newBufferedWriter(propsFile.toPath(), UTF_8);
     new Properties().store(writer, "");
     writer.close();
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -100,7 +101,7 @@ public class TestJarFinder {
       TestJarFinder.class.getName() + "-testNoManifest");
     dir.mkdirs();
     File propsFile = new File(dir, "props.properties");
-    Writer writer = new FileWriter(propsFile);
+    Writer writer = Files.newBufferedWriter(propsFile.toPath(), UTF_8);
     new Properties().store(writer, "");
     writer.close();
     ByteArrayOutputStream baos = new ByteArrayOutputStream();


Mime
View raw message