hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aajis...@apache.org
Subject hadoop git commit: HADOOP-15305. Replace FileUtils.writeStringToFile(File, String) with (File, String, Charset) to fix deprecation warnings.
Date Thu, 15 Mar 2018 07:14:00 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 5ff22d4c3 -> 5e013d50d


HADOOP-15305. Replace FileUtils.writeStringToFile(File, String) with (File, String, Charset)
to fix deprecation warnings.

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5e013d50
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5e013d50
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5e013d50

Branch: refs/heads/trunk
Commit: 5e013d50d1a98d37accf8c6b07b14254ad4f3639
Parents: 5ff22d4
Author: fang zhenyi <fang.zhenyi@zte.com.cn>
Authored: Thu Mar 15 16:11:53 2018 +0900
Committer: Akira Ajisaka <aajisaka@apache.org>
Committed: Thu Mar 15 16:12:07 2018 +0900

----------------------------------------------------------------------
 .../http/server/TestHttpFSServerWebServer.java  |  4 ++--
 .../datamodel/DiskBalancerCluster.java          |  3 ++-
 .../azure/TestShellDecryptionKeyProvider.java   |  4 +++-
 .../utils/PublishedConfigurationOutputter.java  |  3 ++-
 .../yarn/util/DockerClientConfigHandler.java    |  3 ++-
 .../yarn/util/TestProcfsBasedProcessTree.java   |  4 +++-
 .../TestCGroupsResourceCalculator.java          | 21 ++++++++++----------
 7 files changed, 25 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
index a058766..5250543 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
@@ -22,7 +22,7 @@ import java.io.File;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.net.URL;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.text.MessageFormat;
 
 import org.apache.commons.io.FileUtils;
@@ -61,7 +61,7 @@ public class TestHttpFSServerWebServer {
     System.setProperty("httpfs.log.dir", logsDir.getAbsolutePath());
     System.setProperty("httpfs.config.dir", confDir.getAbsolutePath());
     FileUtils.writeStringToFile(new File(confDir, "httpfs-signature.secret"),
-        "foo", Charset.forName("UTF-8"));
+        "foo", StandardCharsets.UTF_8);
   }
 
   @Before

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
index 2f54141..8de19aa 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hdfs.web.JsonUtil;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -284,7 +285,7 @@ public class DiskBalancerCluster {
   public void createSnapshot(String snapShotName) throws IOException {
     String json = this.toJson();
     File outFile = new File(getOutput() + "/" + snapShotName);
-    FileUtils.writeStringToFile(outFile, json);
+    FileUtils.writeStringToFile(outFile, json, StandardCharsets.UTF_8);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestShellDecryptionKeyProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestShellDecryptionKeyProvider.java
b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestShellDecryptionKeyProvider.java
index 0334c39..f863e66 100644
--- a/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestShellDecryptionKeyProvider.java
+++ b/hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestShellDecryptionKeyProvider.java
@@ -21,6 +21,7 @@ package org.apache.hadoop.fs.azure;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
@@ -65,7 +66,8 @@ public class TestShellDecryptionKeyProvider
     // Create a simple script which echoes the given key plus the given
     // expected result (so that we validate both script input and output)
     File scriptFile = new File(TEST_ROOT_DIR, "testScript.cmd");
-    FileUtils.writeStringToFile(scriptFile, "@echo %1 " + expectedResult);
+    FileUtils.writeStringToFile(scriptFile, "@echo %1 " + expectedResult,
+            StandardCharsets.UTF_8);
 
     ShellDecryptionKeyProvider provider = new ShellDecryptionKeyProvider();
     Configuration conf = new Configuration();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfigurationOutputter.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfigurationOutputter.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfigurationOutputter.java
index 88ecf2c..8bdc102 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfigurationOutputter.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/utils/PublishedConfigurationOutputter.java
@@ -32,6 +32,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.Properties;
 
 /**
@@ -61,7 +62,7 @@ public abstract class PublishedConfigurationOutputter {
   }
 */
   public void save(File dest) throws IOException {
-    FileUtils.writeStringToFile(dest, asString(), Charsets.UTF_8);
+    FileUtils.writeStringToFile(dest, asString(), StandardCharsets.UTF_8);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java
index 98bdbdd..13c576b2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/DockerClientConfigHandler.java
@@ -39,6 +39,7 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 
 /**
@@ -178,6 +179,6 @@ public final class DockerClientConfigHandler {
     rootNode.put(CONFIG_AUTHS_KEY, registryUrlNode);
     String json =
         mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rootNode);
-    FileUtils.writeStringToFile(outConfigFile, json, Charset.defaultCharset());
+    FileUtils.writeStringToFile(outConfigFile, json, StandardCharsets.UTF_8);
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
index 215e5b0..7349d22 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestProcfsBasedProcessTree.java
@@ -30,6 +30,7 @@ import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Random;
 import java.util.Vector;
@@ -154,7 +155,8 @@ public class TestProcfsBasedProcessTree {
         + " $(($1-1))\n" + "else\n" + " echo $$ > " + lowestDescendant + "\n"
         + "(sleep 300&\n"
         + "echo $! > " + lostDescendant + ")\n"
-        + " while true\n do\n" + "  sleep 5\n" + " done\n" + "fi");
+        + " while true\n do\n" + "  sleep 5\n" + " done\n" + "fi",
+            StandardCharsets.UTF_8);
 
     Thread t = new RogueTaskThread();
     t.start();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/5e013d50/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsResourceCalculator.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsResourceCalculator.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsResourceCalculator.java
index a2ad11f..0158bc2 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsResourceCalculator.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/linux/resources/TestCGroupsResourceCalculator.java
@@ -26,6 +26,7 @@ import org.junit.Assert;
 import org.junit.Test;
 
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 
 import static org.mockito.Mockito.*;
 
@@ -62,7 +63,7 @@ public class TestCGroupsResourceCalculator {
           new File(procfs, CGroupsResourceCalculator.CGROUP),
           "7:devices:/yarn/container_1\n" +
               "6:cpuacct,cpu:/yarn/container_1\n" +
-              "5:pids:/yarn/container_1\n");
+              "5:pids:/yarn/container_1\n", StandardCharsets.UTF_8);
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
               "1234", basePath,
@@ -84,7 +85,7 @@ public class TestCGroupsResourceCalculator {
           "7:devices:/yarn/container_1\n" +
               "6:cpuacct,cpu:/yarn/container_1\n" +
               "5:pids:/yarn/container_1\n" +
-              "4:memory:/yarn/container_1\n");
+              "4:memory:/yarn/container_1\n", StandardCharsets.UTF_8);
 
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
@@ -118,12 +119,12 @@ public class TestCGroupsResourceCalculator {
           "7:devices:/yarn/container_1\n" +
               "6:cpuacct,cpu:/yarn/container_1\n" +
               "5:pids:/yarn/container_1\n" +
-              "4:memory:/yarn/container_1\n");
+              "4:memory:/yarn/container_1\n", StandardCharsets.UTF_8);
       FileUtils.writeStringToFile(
           new File(cgcpuacctContainerDir, CGroupsResourceCalculator.CPU_STAT),
           "Can you handle this?\n" +
               "user 5415\n" +
-              "system 3632");
+              "system 3632", StandardCharsets.UTF_8);
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
               "1234", basePath,
@@ -159,10 +160,10 @@ public class TestCGroupsResourceCalculator {
       FileUtils.writeStringToFile(
           new File(procfs, CGroupsResourceCalculator.CGROUP),
               "6:cpuacct,cpu:/yarn/container_1\n" +
-              "4:memory:/yarn/container_1\n");
+              "4:memory:/yarn/container_1\n", StandardCharsets.UTF_8);
       FileUtils.writeStringToFile(
           new File(cgMemoryContainerDir, CGroupsResourceCalculator.MEM_STAT),
-          "418496512\n");
+          "418496512\n", StandardCharsets.UTF_8);
 
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
@@ -182,7 +183,7 @@ public class TestCGroupsResourceCalculator {
       // Test the case where memsw is available
       FileUtils.writeStringToFile(
           new File(cgMemoryContainerDir, CGroupsResourceCalculator.MEMSW_STAT),
-          "418496513\n");
+          "418496513\n", StandardCharsets.UTF_8);
       calculator.updateProcessTree();
       Assert.assertEquals("Incorrect swap usage",
           418496513,
@@ -206,7 +207,7 @@ public class TestCGroupsResourceCalculator {
       FileUtils.writeStringToFile(
           new File(cgcpuacctRootDir, CGroupsResourceCalculator.CPU_STAT),
               "user 5415\n" +
-              "system 3632");
+              "system 3632", StandardCharsets.UTF_8);
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
               null, basePath,
@@ -241,7 +242,7 @@ public class TestCGroupsResourceCalculator {
     try {
       FileUtils.writeStringToFile(
           new File(cgMemoryRootDir, CGroupsResourceCalculator.MEM_STAT),
-          "418496512\n");
+              "418496512\n", StandardCharsets.UTF_8);
 
       CGroupsResourceCalculator calculator =
           new CGroupsResourceCalculator(
@@ -262,7 +263,7 @@ public class TestCGroupsResourceCalculator {
       // Test the case where memsw is available
       FileUtils.writeStringToFile(
           new File(cgMemoryRootDir, CGroupsResourceCalculator.MEMSW_STAT),
-          "418496513\n");
+          "418496513\n", StandardCharsets.UTF_8);
       calculator.updateProcessTree();
       Assert.assertEquals("Incorrect swap usage",
           418496513,


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message