This is an automated email from the ASF dual-hosted git repository. ctubbsii pushed a commit to branch 3.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/3.1 by this push: new 1d365a9089 Add UTF-8 charsets to String/Byte conversions in main (#4847) 1d365a9089 is described below commit 1d365a9089ad00420a197615ec01026616ccb499 Author: John K <69256191+meatballspaghe...@users.noreply.github.com> AuthorDate: Wed Aug 28 17:50:21 2024 -0400 Add UTF-8 charsets to String/Byte conversions in main (#4847) - Apply same changes to code in main branch that was not covered in 2.1: - Add UTF-8 charset to String.getBytes calls. - Add UTF-8 charset to new String constructions that use a byte[] as argument. Fixes #4765 --- .../java/org/apache/accumulo/core/file/rfile/AbstractRFileTest.java | 4 +++- .../apache/accumulo/core/iterators/user/IndexedDocIteratorTest.java | 2 +- .../java/org/apache/accumulo/hadoop/its/mapreduce/MapReduceIT.java | 5 +++-- .../minicluster/MiniAccumuloClusterExistingZooKeepersTest.java | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/AbstractRFileTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/AbstractRFileTest.java index 26d7a4baf5..a5fc04a854 100644 --- a/core/src/test/java/org/apache/accumulo/core/file/rfile/AbstractRFileTest.java +++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/AbstractRFileTest.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.core.file.rfile; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -237,7 +238,8 @@ public abstract class AbstractRFileTest { } static Key newKey(String row, String cf, String cq, String cv, long ts) { - return new Key(row.getBytes(), cf.getBytes(), cq.getBytes(), cv.getBytes(), ts); + return new Key(row.getBytes(UTF_8), cf.getBytes(UTF_8), cq.getBytes(UTF_8), cv.getBytes(UTF_8), + ts); } static Value newValue(String val) { diff --git a/core/src/test/java/org/apache/accumulo/core/iterators/user/IndexedDocIteratorTest.java b/core/src/test/java/org/apache/accumulo/core/iterators/user/IndexedDocIteratorTest.java index 57f19f6de7..b1db38be7f 100644 --- a/core/src/test/java/org/apache/accumulo/core/iterators/user/IndexedDocIteratorTest.java +++ b/core/src/test/java/org/apache/accumulo/core/iterators/user/IndexedDocIteratorTest.java @@ -129,7 +129,7 @@ public class IndexedDocIteratorTest { } } sb.append(" docID=").append(doc); - Key k = new Key(row, docColf, new Text(String.format("%010d", docid).getBytes())); + Key k = new Key(row, docColf, new Text(String.format("%010d", docid).getBytes(UTF_8))); map.put(k, new Value(sb.toString())); } } diff --git a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/MapReduceIT.java b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/MapReduceIT.java index 52b66fab48..8512136f8e 100644 --- a/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/MapReduceIT.java +++ b/hadoop-mapreduce/src/test/java/org/apache/accumulo/hadoop/its/mapreduce/MapReduceIT.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.hadoop.its.mapreduce; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; @@ -95,8 +96,8 @@ public class MapReduceIT extends ConfigurableMacBase { int i = 0; for (Entry<Key,Value> entry : s) { MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] check = Base64.getEncoder().encode(md.digest(("row" + i).getBytes())); - assertEquals(entry.getValue().toString(), new String(check)); + byte[] check = Base64.getEncoder().encode(md.digest(("row" + i).getBytes(UTF_8))); + assertEquals(entry.getValue().toString(), new String(check, UTF_8)); i++; } } diff --git a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterExistingZooKeepersTest.java b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterExistingZooKeepersTest.java index fdff86ee3e..c428127b58 100644 --- a/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterExistingZooKeepersTest.java +++ b/minicluster/src/test/java/org/apache/accumulo/minicluster/MiniAccumuloClusterExistingZooKeepersTest.java @@ -18,6 +18,7 @@ */ package org.apache.accumulo.minicluster; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -79,7 +80,7 @@ public class MiniAccumuloClusterExistingZooKeepersTest extends WithTestNames { CuratorFrameworkFactory.newClient(zooKeeper.getConnectString(), new RetryOneTime(1))) { curatorClient.start(); assertNotNull(curatorClient.checkExists().forPath(zkTablePath)); - assertEquals(tableName, new String(curatorClient.getData().forPath(zkTablePath))); + assertEquals(tableName, new String(curatorClient.getData().forPath(zkTablePath), UTF_8)); } } }