From 1570bddb79307eceb05766f6254b60643be5dcab Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Wed, 9 Dec 2020 07:22:31 +0530 Subject: [PATCH] YARN-10491. Fix deprecation warnings in SLSWebApp.java (#2519) Signed-off-by: Akira Ajisaka (cherry picked from commit aaf9e3d320a9d11d2fd8c86fb5fa4e2d1c45d9ef) --- .../java/org/apache/hadoop/yarn/sls/web/SLSWebApp.java | 7 ++++--- .../java/org/apache/hadoop/yarn/sls/web/TestSLSWebApp.java | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/web/SLSWebApp.java b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/web/SLSWebApp.java index c7ba9eef623..b3b7a824038 100644 --- a/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/web/SLSWebApp.java +++ b/hadoop-tools/hadoop-sls/src/main/java/org/apache/hadoop/yarn/sls/web/SLSWebApp.java @@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.sls.web; import java.io.IOException; import java.io.ObjectInputStream; +import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -94,11 +95,11 @@ public class SLSWebApp extends HttpServlet { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { simulateInfoTemplate = IOUtils.toString( - cl.getResourceAsStream("html/simulate.info.html.template")); + cl.getResourceAsStream("html/simulate.info.html.template"), StandardCharsets.UTF_8); simulateTemplate = IOUtils.toString( - cl.getResourceAsStream("html/simulate.html.template")); + cl.getResourceAsStream("html/simulate.html.template"), StandardCharsets.UTF_8); trackTemplate = IOUtils.toString( - cl.getResourceAsStream("html/track.html.template")); + cl.getResourceAsStream("html/track.html.template"), StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); } diff --git a/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/web/TestSLSWebApp.java b/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/web/TestSLSWebApp.java index c9be450fee2..c3f66a0b74d 100644 --- a/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/web/TestSLSWebApp.java +++ b/hadoop-tools/hadoop-sls/src/test/java/org/apache/hadoop/yarn/sls/web/TestSLSWebApp.java @@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Test; import java.io.File; +import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.HashSet; import java.util.Map; @@ -34,7 +35,7 @@ public class TestSLSWebApp { @Test public void testSimulateInfoPageHtmlTemplate() throws Exception { String simulateInfoTemplate = FileUtils.readFileToString( - new File("src/main/html/simulate.info.html.template")); + new File("src/main/html/simulate.info.html.template"), StandardCharsets.UTF_8); Map simulateInfoMap = new HashMap<>(); simulateInfoMap.put("Number of racks", 10); @@ -72,7 +73,7 @@ public class TestSLSWebApp { @Test public void testSimulatePageHtmlTemplate() throws Exception { String simulateTemplate = FileUtils.readFileToString( - new File("src/main/html/simulate.html.template")); + new File("src/main/html/simulate.html.template"), StandardCharsets.UTF_8); Set queues = new HashSet(); queues.add("sls_queue_1"); @@ -96,7 +97,7 @@ public class TestSLSWebApp { @Test public void testTrackPageHtmlTemplate() throws Exception { String trackTemplate = FileUtils.readFileToString( - new File("src/main/html/track.html.template")); + new File("src/main/html/track.html.template"), StandardCharsets.UTF_8); String trackedQueueInfo = ""; Set trackedQueues = new HashSet(); trackedQueues.add("sls_queue_1");