You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/07/18 03:24:57 UTC
[incubator-iotdb] branch master updated: Change String literal
"UTF-8" into StandardCharsets.UTF_8
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 327d2b2 Change String literal "UTF-8" into StandardCharsets.UTF_8
new 6d297df Merge pull request #257 from Genius-pig/master
327d2b2 is described below
commit 327d2b26b76cdf02a33981491801ddcebb53cbec
Author: zhutianci <zh...@gmail.com>
AuthorDate: Wed Jul 17 19:11:53 2019 +0800
Change String literal "UTF-8" into StandardCharsets.UTF_8
---
.../apache/iotdb/db/exception/builder/ExceptionBuilder.java | 3 ++-
.../org/apache/iotdb/db/exception/ExceptionBuilderTest.java | 5 +++--
.../java/org/apache/iotdb/tsfile/compress/CompressTest.java | 13 +++++++------
.../java/org/apache/iotdb/tsfile/compress/SnappyTest.java | 3 ++-
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java b/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
index 784c198..2055bce 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/exception/builder/ExceptionBuilder.java
@@ -24,6 +24,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.Properties;
import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBConstant;
@@ -60,7 +61,7 @@ public class ExceptionBuilder {
*/
public void loadInfo(String filePath) {
try(InputStream in = new BufferedInputStream(new FileInputStream(filePath))){
- properties.load(new InputStreamReader(in, "utf-8"));
+ properties.load(new InputStreamReader(in, StandardCharsets.UTF_8));
} catch (IOException e) {
logger.error(
"Read file error. File does not exist or file is broken. "
diff --git a/iotdb/src/test/java/org/apache/iotdb/db/exception/ExceptionBuilderTest.java b/iotdb/src/test/java/org/apache/iotdb/db/exception/ExceptionBuilderTest.java
index 59b9a4f..d5b9d7b 100644
--- a/iotdb/src/test/java/org/apache/iotdb/db/exception/ExceptionBuilderTest.java
+++ b/iotdb/src/test/java/org/apache/iotdb/db/exception/ExceptionBuilderTest.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Properties;
import org.apache.iotdb.db.exception.builder.ExceptionBuilder;
import org.junit.After;
@@ -49,7 +50,7 @@ public class ExceptionBuilderTest {
prop.setProperty("20130", "Statement not prepared");
prop.setProperty("20220", "Fail to connect");
- prop.store(new OutputStreamWriter(out1, "utf-8"), "english version");
+ prop.store(new OutputStreamWriter(out1, StandardCharsets.UTF_8), "english version");
out2 = new FileOutputStream("err_info_cn.properties", true);
prop.setProperty("20000", "未知错误");
@@ -62,7 +63,7 @@ public class ExceptionBuilderTest {
prop.setProperty("20130", "语句未就绪");
prop.setProperty("20220", "连接失败");
- prop.store(new OutputStreamWriter(out2, "utf-8"), "chinese version");
+ prop.store(new OutputStreamWriter(out2, StandardCharsets.UTF_8), "chinese version");
} catch (Exception e) {
e.printStackTrace();
} finally {
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/CompressTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/CompressTest.java
index bd77c67..1c30c8e 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/CompressTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/CompressTest.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.tsfile.compress;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.apache.iotdb.tsfile.utils.PublicBAOS;
import org.junit.After;
@@ -49,35 +50,35 @@ public class CompressTest {
@Test
public void snappyCompressorTest1() throws IOException {
PublicBAOS out = new PublicBAOS();
- out.write(inputString.getBytes("UTF-8"));
+ out.write(inputString.getBytes(StandardCharsets.UTF_8));
ICompressor.SnappyCompressor compressor = new ICompressor.SnappyCompressor();
IUnCompressor.SnappyUnCompressor unCompressor = new IUnCompressor.SnappyUnCompressor();
byte[] compressed = compressor.compress(out.getBuf());
byte[] uncompressed = unCompressor.uncompress(compressed);
- String result = new String(uncompressed, "UTF-8");
+ String result = new String(uncompressed, StandardCharsets.UTF_8);
assertEquals(inputString, result);
}
@Test
public void snappyCompressorTest2() throws IOException {
PublicBAOS out = new PublicBAOS();
- out.write(inputString.getBytes("UTF-8"));
+ out.write(inputString.getBytes(StandardCharsets.UTF_8));
ICompressor.SnappyCompressor compressor = new ICompressor.SnappyCompressor();
IUnCompressor.SnappyUnCompressor unCompressor = new IUnCompressor.SnappyUnCompressor();
byte[] compressed = new byte[compressor.getMaxBytesForCompression(out.size())];
int size = compressor.compress(out.getBuf(), 0, out.size(), compressed);
byte[] bytes = Arrays.copyOfRange(compressed, 0, size);
byte[] uncompressed = unCompressor.uncompress(bytes);
- String result = new String(uncompressed, "UTF-8");
+ String result = new String(uncompressed, StandardCharsets.UTF_8);
assertEquals(inputString, result);
}
@Test
public void snappyTest() throws IOException {
- byte[] compressed = Snappy.compress(inputString.getBytes("UTF-8"));
+ byte[] compressed = Snappy.compress(inputString.getBytes(StandardCharsets.UTF_8));
byte[] uncompressed = Snappy.uncompress(compressed);
- String result = new String(uncompressed, "UTF-8");
+ String result = new String(uncompressed, StandardCharsets.UTF_8);
assertEquals(inputString, result);
}
diff --git a/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/SnappyTest.java b/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/SnappyTest.java
index 3c640d7..aced779 100644
--- a/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/SnappyTest.java
+++ b/tsfile/src/test/java/org/apache/iotdb/tsfile/compress/SnappyTest.java
@@ -20,6 +20,7 @@ package org.apache.iotdb.tsfile.compress;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.iotdb.tsfile.utils.ReadWriteIOUtils;
import org.junit.After;
@@ -51,7 +52,7 @@ public class SnappyTest {
@Test
public void testBytes() throws IOException {
String input = randomString(50000);
- byte[] uncom = input.getBytes("UTF-8");
+ byte[] uncom = input.getBytes(StandardCharsets.UTF_8);
long time = System.currentTimeMillis();
byte[] compressed = Snappy.compress(uncom);
System.out.println("compression time cost:" + (System.currentTimeMillis() - time));