HADOOP-17956. Replace all default Charset usage with UTF-8 (#3529)
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
7279fe8661
commit
1151edf12e
|
@ -46,7 +46,7 @@ import java.io.InputStream;
|
|||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -924,7 +924,7 @@ public class KDiag extends Configured implements Tool, Closeable {
|
|||
*/
|
||||
private void dump(File file) throws IOException {
|
||||
try (InputStream in = Files.newInputStream(file.toPath())) {
|
||||
for (String line : IOUtils.readLines(in, Charset.defaultCharset())) {
|
||||
for (String line : IOUtils.readLines(in, StandardCharsets.UTF_8)) {
|
||||
println("%s", line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.hadoop.classification.VisibleForTesting;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
@ -225,8 +225,7 @@ public final class ProviderUtils {
|
|||
throw new IOException("Password file does not exist");
|
||||
}
|
||||
try (InputStream is = pwdFile.openStream()) {
|
||||
pass = IOUtils.toString(is, Charset.defaultCharset()).trim()
|
||||
.toCharArray();
|
||||
pass = IOUtils.toString(is, StandardCharsets.UTF_8).trim().toCharArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collections;
|
||||
|
@ -223,8 +222,7 @@ public class ShellBasedIdMapping implements IdMappingServiceProvider {
|
|||
Process process = Runtime.getRuntime().exec(
|
||||
new String[] { "bash", "-c", command });
|
||||
br = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream(),
|
||||
Charset.defaultCharset()));
|
||||
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] nameId = line.split(regex);
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.lang.management.ThreadMXBean;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
@ -244,7 +244,7 @@ public class ReflectionUtils {
|
|||
try {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
|
||||
log.info(buffer.toString(Charset.defaultCharset().name()));
|
||||
log.info(buffer.toString(StandardCharsets.UTF_8.name()));
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class ReflectionUtils {
|
|||
try {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
printThreadInfo(new PrintStream(buffer, false, "UTF-8"), title);
|
||||
log.info(buffer.toString(Charset.defaultCharset().name()));
|
||||
log.info(buffer.toString(StandardCharsets.UTF_8.name()));
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
@ -949,11 +949,11 @@ public abstract class Shell {
|
|||
timeOutTimer.schedule(timeoutTimerTask, timeOutInterval);
|
||||
}
|
||||
final BufferedReader errReader =
|
||||
new BufferedReader(new InputStreamReader(
|
||||
process.getErrorStream(), Charset.defaultCharset()));
|
||||
new BufferedReader(new InputStreamReader(process.getErrorStream(),
|
||||
StandardCharsets.UTF_8));
|
||||
BufferedReader inReader =
|
||||
new BufferedReader(new InputStreamReader(
|
||||
process.getInputStream(), Charset.defaultCharset()));
|
||||
new BufferedReader(new InputStreamReader(process.getInputStream(),
|
||||
StandardCharsets.UTF_8));
|
||||
final StringBuffer errMsg = new StringBuffer();
|
||||
|
||||
// read error and input streams as this would free up the buffers
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.io.InputStream;
|
|||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class TestTextCommand {
|
|||
|
||||
private String inputStreamToString(InputStream stream) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(stream, writer, Charset.defaultCharset());
|
||||
IOUtils.copy(stream, writer, StandardCharsets.UTF_8);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class TestKDiag extends Assert {
|
|||
*/
|
||||
private void dump(File file) throws IOException {
|
||||
try (FileInputStream in = new FileInputStream(file)) {
|
||||
for (String line : IOUtils.readLines(in, Charset.defaultCharset())) {
|
||||
for (String line : IOUtils.readLines(in, StandardCharsets.UTF_8)) {
|
||||
LOG.info(line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ import java.io.IOException;
|
|||
import java.io.Writer;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Principal;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
@ -555,8 +555,7 @@ public class TestWebDelegationToken {
|
|||
HttpURLConnection conn = aUrl.openConnection(url, token);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
List<String> ret = IOUtils.readLines(conn.getInputStream(),
|
||||
Charset.defaultCharset());
|
||||
List<String> ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(FOO_USER, ret.get(0));
|
||||
|
||||
|
@ -626,8 +625,7 @@ public class TestWebDelegationToken {
|
|||
HttpURLConnection conn = aUrl.openConnection(url, token);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
List<String> ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
List<String> ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(FOO_USER, ret.get(0));
|
||||
|
||||
|
@ -851,15 +849,14 @@ public class TestWebDelegationToken {
|
|||
HttpURLConnection conn =
|
||||
(HttpURLConnection) new URL(strUrl).openConnection();
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
|
||||
List<String> ret =
|
||||
IOUtils.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
List<String> ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(OK_USER, ret.get(0));
|
||||
strUrl = String.format("%s?user.name=%s&DOAS=%s", url.toExternalForm(),
|
||||
FOO_USER, OK_USER);
|
||||
conn = (HttpURLConnection) new URL(strUrl).openConnection();
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
|
||||
ret = IOUtils.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(OK_USER, ret.get(0));
|
||||
|
||||
|
@ -877,7 +874,7 @@ public class TestWebDelegationToken {
|
|||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
List<String> ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(OK_USER, ret.get(0));
|
||||
|
||||
|
@ -898,7 +895,7 @@ public class TestWebDelegationToken {
|
|||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals(FOO_USER, ret.get(0));
|
||||
|
||||
|
@ -960,7 +957,7 @@ public class TestWebDelegationToken {
|
|||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
List<String> ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals("remoteuser=" + FOO_USER+ ":ugi=" + FOO_USER,
|
||||
ret.get(0));
|
||||
|
@ -969,8 +966,7 @@ public class TestWebDelegationToken {
|
|||
conn = aUrl.openConnection(url, token, OK_USER);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals("realugi=" + FOO_USER +":remoteuser=" + OK_USER +
|
||||
":ugi=" + OK_USER, ret.get(0));
|
||||
|
@ -1022,8 +1018,7 @@ public class TestWebDelegationToken {
|
|||
HttpURLConnection conn = aUrl.openConnection(url, token, OK_USER);
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK,
|
||||
conn.getResponseCode());
|
||||
List<String> ret = IOUtils
|
||||
.readLines(conn.getInputStream(), Charset.defaultCharset());
|
||||
List<String> ret = IOUtils.readLines(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(1, ret.size());
|
||||
Assert.assertEquals("realugi=" + FOO_USER +":remoteuser=" + OK_USER +
|
||||
":ugi=" + OK_USER, ret.get(0));
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.hadoop.util.Shell;
|
|||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -113,10 +113,9 @@ public class StatUtils {
|
|||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.awaitTermination(2000, TimeUnit.MILLISECONDS);
|
||||
try {
|
||||
Future<String> future =
|
||||
executorService.submit(() -> new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream(),
|
||||
Charset.defaultCharset())).lines().findFirst().orElse(""));
|
||||
Future<String> future = executorService.submit(() -> new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)).lines()
|
||||
.findFirst().orElse(""));
|
||||
return future.get();
|
||||
} finally {
|
||||
process.destroy();
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
@ -135,7 +135,7 @@ public class TestApplicationClassLoader {
|
|||
|
||||
InputStream in = appClassloader.getResourceAsStream("resource.txt");
|
||||
assertNotNull("Resource should not be null for app classloader", in);
|
||||
assertEquals("hello", IOUtils.toString(in, Charset.defaultCharset()));
|
||||
assertEquals("hello", IOUtils.toString(in, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private File makeTestJar() throws IOException {
|
||||
|
|
|
@ -49,7 +49,7 @@ import javax.security.auth.login.LoginException;
|
|||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Principal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
|
@ -220,7 +220,7 @@ public class AbstractSecureRegistryTest extends RegistryTestHelper {
|
|||
BOB_LOCALHOST, keytab_bob));
|
||||
|
||||
jaasFile = new File(kdcWorkDir, "jaas.txt");
|
||||
FileUtils.write(jaasFile, jaas.toString(), Charset.defaultCharset());
|
||||
FileUtils.write(jaasFile, jaas.toString(), StandardCharsets.UTF_8);
|
||||
LOG.info("\n"+ jaas);
|
||||
RegistrySecurity.bindJVMtoJAASFile(jaasFile);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.registry.secure;
|
|||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Principal;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.HashMap;
|
||||
|
@ -93,8 +93,7 @@ public class TestSecureLogins extends AbstractSecureRegistryTest {
|
|||
logLoginDetails(ALICE_LOCALHOST, client);
|
||||
String confFilename = System.getProperty(Environment.JAAS_CONF_KEY);
|
||||
assertNotNull("Unset: "+ Environment.JAAS_CONF_KEY, confFilename);
|
||||
String config = FileUtils.readFileToString(new File(confFilename),
|
||||
Charset.defaultCharset());
|
||||
String config = FileUtils.readFileToString(new File(confFilename), StandardCharsets.UTF_8);
|
||||
LOG.info("{}=\n{}", confFilename, config);
|
||||
RegistrySecurity.setZKSaslClientProperties(ALICE, ALICE_CLIENT_CONTEXT);
|
||||
} finally {
|
||||
|
@ -133,8 +132,7 @@ public class TestSecureLogins extends AbstractSecureRegistryTest {
|
|||
@Test
|
||||
public void testKerberosAuth() throws Throwable {
|
||||
File krb5conf = getKdc().getKrb5conf();
|
||||
String krbConfig = FileUtils.readFileToString(krb5conf,
|
||||
Charset.defaultCharset());
|
||||
String krbConfig = FileUtils.readFileToString(krb5conf, StandardCharsets.UTF_8);
|
||||
LOG.info("krb5.conf at {}:\n{}", krb5conf, krbConfig);
|
||||
Subject subject = new Subject();
|
||||
Class<?> kerb5LoginClass =
|
||||
|
|
|
@ -57,7 +57,7 @@ import java.io.Writer;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -1711,8 +1711,7 @@ public class TestHttpFSServer extends HFSTestCase {
|
|||
conn.connect();
|
||||
// Verify that we read what we wrote
|
||||
Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
|
||||
String content = IOUtils.toString(
|
||||
conn.getInputStream(), Charset.defaultCharset());
|
||||
String content = IOUtils.toString(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
Assert.assertEquals(testContent, content);
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan;
|
|||
import org.apache.hadoop.hdfs.tools.DiskBalancerCLI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Cancels a running plan.
|
||||
|
@ -77,7 +77,7 @@ public class CancelCommand extends Command {
|
|||
"Invalid plan file specified.");
|
||||
String planData = null;
|
||||
try (FSDataInputStream plan = open(planFile)) {
|
||||
planData = IOUtils.toString(plan, Charset.defaultCharset());
|
||||
planData = IOUtils.toString(plan, StandardCharsets.UTF_8);
|
||||
}
|
||||
cancelPlan(planData);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan;
|
|||
import org.apache.hadoop.hdfs.tools.DiskBalancerCLI;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* executes a given plan.
|
||||
|
@ -69,7 +69,7 @@ public class ExecuteCommand extends Command {
|
|||
|
||||
String planData = null;
|
||||
try (FSDataInputStream plan = open(planFile)) {
|
||||
planData = IOUtils.toString(plan, Charset.defaultCharset());
|
||||
planData = IOUtils.toString(plan, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
boolean skipDateCheck = false;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
|
@ -107,7 +107,7 @@ public class TestHdfsTextCommand {
|
|||
|
||||
private String inputStreamToString(InputStream stream) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(stream, writer, Charset.defaultCharset());
|
||||
IOUtils.copy(stream, writer, StandardCharsets.UTF_8);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -126,8 +126,7 @@ public class TestOfflineImageViewerForXAttr {
|
|||
|
||||
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
|
||||
|
||||
String content = IOUtils
|
||||
.toString(connection.getInputStream(), Charset.defaultCharset());
|
||||
String content = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
assertTrue("Missing user.attr1 in response ",
|
||||
content.contains("user.attr1"));
|
||||
|
@ -152,8 +151,7 @@ public class TestOfflineImageViewerForXAttr {
|
|||
connection.connect();
|
||||
|
||||
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
|
||||
String content = IOUtils
|
||||
.toString(connection.getInputStream(), Charset.defaultCharset());
|
||||
String content = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
assertTrue("Missing user.attr1 in response ",
|
||||
content.contains("user.attr1"));
|
||||
|
@ -186,8 +184,7 @@ public class TestOfflineImageViewerForXAttr {
|
|||
connection.connect();
|
||||
|
||||
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
|
||||
String content = IOUtils
|
||||
.toString(connection.getInputStream(), Charset.defaultCharset());
|
||||
String content = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
assertEquals(attr1JSon, content);
|
||||
}
|
||||
}
|
||||
|
@ -209,8 +206,7 @@ public class TestOfflineImageViewerForXAttr {
|
|||
connection.connect();
|
||||
|
||||
assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
|
||||
String content = IOUtils
|
||||
.toString(connection.getInputStream(), Charset.defaultCharset());
|
||||
String content = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
|
||||
assertEquals(attr1JSon, content);
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ import java.net.SocketTimeoutException;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Arrays;
|
||||
|
@ -1554,7 +1553,7 @@ public class TestWebHDFS {
|
|||
conn.setRequestMethod(TYPE);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
String response =
|
||||
IOUtils.toString(conn.getInputStream(), Charset.defaultCharset());
|
||||
IOUtils.toString(conn.getInputStream(), StandardCharsets.UTF_8);
|
||||
LOG.info("Response was : " + response);
|
||||
Assert.assertEquals(
|
||||
"Response wasn't " + HttpURLConnection.HTTP_OK,
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Iterator;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
|
@ -135,8 +135,7 @@ public class TestJavaSerialization {
|
|||
new Utils.OutputFileUtils.OutputFilesFilter()));
|
||||
assertEquals(1, outputFiles.length);
|
||||
try (InputStream is = fs.open(outputFiles[0])) {
|
||||
String reduceOutput =
|
||||
org.apache.commons.io.IOUtils.toString(is, Charset.defaultCharset());
|
||||
String reduceOutput = org.apache.commons.io.IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||
String[] lines = reduceOutput.split("\n");
|
||||
assertEquals("Unexpected output; received output '" + reduceOutput + "'",
|
||||
"a\t1", lines[0]);
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
|
@ -437,8 +437,7 @@ public class TestFrameworkUploader {
|
|||
// Create a target file
|
||||
File targetFile = new File(parent, "a.txt");
|
||||
try(FileOutputStream os = new FileOutputStream(targetFile)) {
|
||||
IOUtils.writeLines(Lists.newArrayList("a", "b"), null, os,
|
||||
Charset.defaultCharset());
|
||||
IOUtils.writeLines(Lists.newArrayList("a", "b"), null, os, StandardCharsets.UTF_8);
|
||||
}
|
||||
Assert.assertFalse(uploader.checkSymlink(targetFile));
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
@ -114,7 +114,7 @@ public class ResourceGzMojo extends AbstractMojo {
|
|||
BufferedReader is = Files.newBufferedReader(path)
|
||||
) {
|
||||
getLog().info("Compressing " + path + " to " + outFile);
|
||||
IOUtils.copy(is, os, Charset.defaultCharset());
|
||||
IOUtils.copy(is, os, StandardCharsets.UTF_8);
|
||||
}
|
||||
} else {
|
||||
throw new IOException("Directory " + outFile.getParent()
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.junit.Test;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Random;
|
||||
|
||||
public class TestHadoopArchiveLogs {
|
||||
|
@ -279,8 +279,7 @@ public class TestHadoopArchiveLogs {
|
|||
Assert.assertFalse(localScript.exists());
|
||||
hal.generateScript(localScript);
|
||||
Assert.assertTrue(localScript.exists());
|
||||
String script =
|
||||
IOUtils.toString(localScript.toURI(), Charset.defaultCharset());
|
||||
String script = IOUtils.toString(localScript.toURI(), StandardCharsets.UTF_8);
|
||||
String[] lines = script.split("\n");
|
||||
Assert.assertEquals(22, lines.length);
|
||||
Assert.assertEquals("#!/bin/bash", lines[0]);
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.hadoop.fs.s3a;
|
|||
import javax.net.ssl.SSLException;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.amazonaws.SdkClientException;
|
||||
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||
|
@ -200,8 +200,7 @@ public class TestS3AInputStreamRetry extends AbstractS3AMockTest {
|
|||
* @return mocked object.
|
||||
*/
|
||||
private S3ObjectInputStream getMockedInputStream(boolean triggerFailure) {
|
||||
return new S3ObjectInputStream(
|
||||
IOUtils.toInputStream(INPUT, Charset.defaultCharset()), null) {
|
||||
return new S3ObjectInputStream(IOUtils.toInputStream(INPUT, StandardCharsets.UTF_8), null) {
|
||||
|
||||
private final IOException exception =
|
||||
new SSLException(new SocketException("Connection reset"));
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assume;
|
||||
|
@ -168,8 +168,7 @@ public class ITestS3SelectCLI extends AbstractS3SelectTest {
|
|||
o(OPT_OUTPUT), localFile.toString(),
|
||||
landsatSrc,
|
||||
SELECT_SUNNY_ROWS_NO_LIMIT);
|
||||
List<String> lines = IOUtils.readLines(new FileInputStream(localFile),
|
||||
Charset.defaultCharset());
|
||||
List<String> lines = IOUtils.readLines(new FileInputStream(localFile), StandardCharsets.UTF_8);
|
||||
LOG.info("Result from select:\n{}", lines.get(0));
|
||||
assertEquals(lineCount, lines.size());
|
||||
selectCount.assertDiffEquals("select count", 1);
|
||||
|
|
|
@ -97,7 +97,7 @@ import java.net.InetSocketAddress;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
@ -549,7 +549,7 @@ public class ServiceScheduler extends CompositeService {
|
|||
case TEMPLATE:
|
||||
try (FSDataInputStream fileInput = fileSystem
|
||||
.open(new Path(key.getSrcFile()))) {
|
||||
return IOUtils.toString(fileInput, Charset.defaultCharset());
|
||||
return IOUtils.toString(fileInput, StandardCharsets.UTF_8);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -48,7 +48,7 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -466,8 +466,7 @@ public class ProviderUtils implements YarnServiceConstants {
|
|||
content = substituteStrWithTokens(content, tokensForSubstitution);
|
||||
|
||||
try (OutputStream output = fs.create(remoteFile)) {
|
||||
org.apache.commons.io.IOUtils
|
||||
.write(content, output, Charset.defaultCharset());
|
||||
org.apache.commons.io.IOUtils.write(content, output, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
log.info("Failed to create " + remoteFile);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public final class DockerClientConfigHandler {
|
|||
if (fs != null) {
|
||||
FSDataInputStream fileHandle = fs.open(configFile);
|
||||
if (fileHandle != null) {
|
||||
contents = IOUtils.toString(fileHandle, Charset.defaultCharset());
|
||||
contents = IOUtils.toString(fileHandle, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
if (contents == null) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.hadoop.yarn.server.federation.resolver;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -107,7 +107,7 @@ public class DefaultSubClusterResolverImpl extends AbstractSubClusterResolver
|
|||
}
|
||||
|
||||
try {
|
||||
reader = Files.newBufferedReader(file, Charset.defaultCharset());
|
||||
reader = Files.newBufferedReader(file, StandardCharsets.UTF_8);
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] tokens = line.split(",");
|
||||
|
|
|
@ -54,7 +54,7 @@ import javax.ws.rs.core.Response;
|
|||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -420,7 +420,7 @@ public class LogServlet extends Configured {
|
|||
|
||||
private static StreamingOutput createEmptyStream() {
|
||||
return outputStream -> outputStream.write(
|
||||
"".getBytes(Charset.defaultCharset()));
|
||||
"".getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.OutputStream;
|
|||
import java.io.PrintStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -350,8 +350,7 @@ public abstract class ContainerExecutor implements Configurable {
|
|||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(
|
||||
FileUtils.readFileToString(file, Charset.defaultCharset()).trim());
|
||||
return Integer.parseInt(FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IOException("Error parsing exit code from pid " + pid, e);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.apache.hadoop.yarn.util.MonotonicClock;
|
|||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
@ -269,9 +269,8 @@ public class CGroupElasticMemoryController extends Thread {
|
|||
|
||||
// Listen to any errors in the background. We do not expect this to
|
||||
// be large in size, so it will fit into a string.
|
||||
Future<String> errorListener = executor.submit(
|
||||
() -> IOUtils.toString(process.getErrorStream(),
|
||||
Charset.defaultCharset()));
|
||||
Future<String> errorListener =
|
||||
executor.submit(() -> IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8));
|
||||
|
||||
// We get Linux event increments (8 bytes) forwarded from the event stream
|
||||
// The events cannot be split, so it is safe to read them as a whole
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.yarn.server.nodemanager;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
|
@ -270,16 +270,14 @@ public class TestContainerExecutor {
|
|||
try {
|
||||
int writtenExitCode = 10;
|
||||
|
||||
FileUtils.writeStringToFile(pidFile, "2992",
|
||||
Charset.defaultCharset(), false);
|
||||
FileUtils.writeStringToFile(pidFile, "2992", StandardCharsets.UTF_8, false);
|
||||
|
||||
TimerTask task = new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FileUtils.writeStringToFile(exitCodeFile,
|
||||
Integer.toString(writtenExitCode),
|
||||
Charset.defaultCharset(), false);
|
||||
FileUtils.writeStringToFile(exitCodeFile, Integer.toString(writtenExitCode),
|
||||
StandardCharsets.UTF_8, false);
|
||||
} catch (IOException ioe) {
|
||||
LOG.warn("Could not write pid file");
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
|
@ -97,8 +97,7 @@ public class TestCGroupElasticMemoryController {
|
|||
script.getAbsolutePath());
|
||||
try {
|
||||
FileUtils.writeStringToFile(script,
|
||||
"#!/bin/bash\nprintf oomevent;printf oomevent;\n",
|
||||
Charset.defaultCharset(), false);
|
||||
"#!/bin/bash\nprintf oomevent;printf oomevent;\n", StandardCharsets.UTF_8, false);
|
||||
assertTrue("Could not set executable",
|
||||
script.setExecutable(true));
|
||||
|
||||
|
@ -138,9 +137,8 @@ public class TestCGroupElasticMemoryController {
|
|||
conf.set(YarnConfiguration.NM_ELASTIC_MEMORY_CONTROL_OOM_LISTENER_PATH,
|
||||
script.getAbsolutePath());
|
||||
try {
|
||||
FileUtils.writeStringToFile(script,
|
||||
"#!/bin/bash\nprintf oomevent;printf oomevent;\n",
|
||||
Charset.defaultCharset(), false);
|
||||
FileUtils.writeStringToFile(script, "#!/bin/bash\nprintf oomevent;printf oomevent;\n",
|
||||
StandardCharsets.UTF_8, false);
|
||||
assertTrue("Could not set executable",
|
||||
script.setExecutable(true));
|
||||
|
||||
|
@ -181,9 +179,8 @@ public class TestCGroupElasticMemoryController {
|
|||
script.getAbsolutePath());
|
||||
Runnable handler = mock(Runnable.class);
|
||||
try {
|
||||
FileUtils.writeStringToFile(script,
|
||||
"#!/bin/bash\nprintf oomevent;sleep 1000;\n",
|
||||
Charset.defaultCharset(), false);
|
||||
FileUtils.writeStringToFile(script, "#!/bin/bash\nprintf oomevent;sleep 1000;\n",
|
||||
StandardCharsets.UTF_8, false);
|
||||
assertTrue("Could not set executable",
|
||||
script.setExecutable(true));
|
||||
|
||||
|
@ -223,9 +220,8 @@ public class TestCGroupElasticMemoryController {
|
|||
script.getAbsolutePath());
|
||||
Runnable handler = mock(Runnable.class);
|
||||
try {
|
||||
FileUtils.writeStringToFile(script,
|
||||
"#!/bin/bash\nprintf oomevent;sleep 1000;\n",
|
||||
Charset.defaultCharset(), false);
|
||||
FileUtils.writeStringToFile(script, "#!/bin/bash\nprintf oomevent;sleep 1000;\n",
|
||||
StandardCharsets.UTF_8, false);
|
||||
assertTrue("Could not set executable",
|
||||
script.setExecutable(true));
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.w3c.dom.Element;
|
|||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -194,8 +194,7 @@ public class TestPlacementRuleFS {
|
|||
Document doc = null;
|
||||
try {
|
||||
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
|
||||
doc = builder.parse(IOUtils.toInputStream(str,
|
||||
Charset.defaultCharset()));
|
||||
doc = builder.parse(IOUtils.toInputStream(str, StandardCharsets.UTF_8));
|
||||
} catch (Exception ex) {
|
||||
fail("Element creation failed, failing test");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue