Skip to content

Commit

Permalink
HADOOP-18917. Addendum. Fix deprecation issues after commons-io upgra…
Browse files Browse the repository at this point in the history
…de. (apache#6228). Contributed by PJ Fanning.
  • Loading branch information
pjfanning authored and jiajunmao committed Feb 6, 2024
1 parent 6d4d733 commit 5cfedde
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void testOfflineImageViewer() throws Exception {
FSImageTestUtil.getFSImage(
cluster.getNameNode()).getStorage().getStorageDir(0));
assertNotNull("Didn't generate or can't find fsimage", originalFsimage);
PrintStream o = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
PrintStream o = new PrintStream(NullOutputStream.INSTANCE);
PBImageXmlWriter v = new PBImageXmlWriter(new Configuration(), o);
v.visit(new RandomAccessFile(originalFsimage, "r"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private static FileStatus pathToFileEntry(FileSystem hdfs, String file)
@Test(expected = IOException.class)
public void testTruncatedFSImage() throws IOException {
File truncatedFile = new File(tempDir, "truncatedFsImage");
PrintStream output = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
PrintStream output = new PrintStream(NullOutputStream.INSTANCE);
copyPartOfFile(originalFsimage, truncatedFile);
try (RandomAccessFile r = new RandomAccessFile(truncatedFile, "r")) {
new FileDistributionCalculator(new Configuration(), 0, 0, false, output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -505,7 +506,10 @@ void generateScript(File localScript) throws IOException {
String classpath = halrJarPath + File.pathSeparator + harJarPath;
FileWriterWithEncoding fw = null;
try {
fw = new FileWriterWithEncoding(localScript, "UTF-8");
fw = FileWriterWithEncoding.builder()
.setFile(localScript)
.setCharset(StandardCharsets.UTF_8)
.get();
fw.write("#!/bin/bash\nset -e\nset -x\n");
int containerCount = 1;
for (AppInfo context : eligibleApplications) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.io.PrintStream;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -783,7 +784,10 @@ public static void readAcontainerLogs(DataInputStream valueStream,
OutputStream os = null;
PrintStream ps = null;
try {
os = new WriterOutputStream(writer, Charset.forName("UTF-8"));
os = WriterOutputStream.builder()
.setWriter(writer)
.setCharset(StandardCharsets.UTF_8)
.get();
ps = new PrintStream(os);
while (true) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,9 @@ void testLevelDbRepair() throws IOException {
store.init(conf);
Mockito.verify(factory, Mockito.times(1))
.repair(Mockito.any(File.class), Mockito.any(Options.class));
FileFilter fileFilter = new WildcardFileFilter(
"*" + LeveldbTimelineStore.BACKUP_EXT + "*");
FileFilter fileFilter = WildcardFileFilter.builder()
.setWildcards("*" + LeveldbTimelineStore.BACKUP_EXT +"*")
.get();
assertTrue(path.listFiles(fileFilter).length > 0);
} finally {
store.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ void testLevelDbRepair() throws IOException {
store.init(conf);
Mockito.verify(factory, Mockito.times(1))
.repair(Mockito.any(File.class), Mockito.any(Options.class));
FilenameFilter fileFilter =
new WildcardFileFilter("*" + RollingLevelDBTimelineStore.BACKUP_EXT + "*");
FilenameFilter fileFilter = WildcardFileFilter.builder()
.setWildcards("*" + RollingLevelDBTimelineStore.BACKUP_EXT + "*")
.get();
assertTrue(new File(path.getAbsolutePath(), RollingLevelDBTimelineStore.FILENAME)
.list(fileFilter).length > 0);
} finally {
Expand Down

0 comments on commit 5cfedde

Please sign in to comment.