Skip to content

Commit 09c4f50

Browse files
authored
HADOOP-18917. Upgrade to commons-io 2.14.0 (#6133) (#6151). Contributed by PJ Fanning.
1 parent 4dd9752 commit 09c4f50

File tree

10 files changed

+29
-24
lines changed

10 files changed

+29
-24
lines changed

LICENSE-binary

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ commons-cli:commons-cli:1.2
250250
commons-codec:commons-codec:1.11
251251
commons-collections:commons-collections:3.2.2
252252
commons-daemon:commons-daemon:1.0.13
253-
commons-io:commons-io:2.8.0
253+
commons-io:commons-io:2.14.0
254254
commons-logging:commons-logging:1.1.3
255255
commons-net:commons-net:3.9.0
256256
de.ruedigermoeller:fst:2.50

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HostRestrictingAuthorizationFilter.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,12 @@ private boolean matchRule(String user, String remoteIp, String path) {
117117
String rulePath = rule.getPath();
118118
LOG.trace("Evaluating rule, subnet: {}, path: {}",
119119
subnet != null ? subnet.getCidrSignature() : "*", rulePath);
120-
try {
121-
if ((subnet == null || subnet.isInRange(remoteIp))
122-
&& FilenameUtils.directoryContains(rulePath, path)) {
123-
LOG.debug("Found matching rule, subnet: {}, path: {}; returned true",
124-
rule.getSubnet() != null ? subnet.getCidrSignature() : null,
125-
rulePath);
126-
return true;
127-
}
128-
} catch (IOException e) {
129-
LOG.warn("Got IOException {}; returned false", e);
130-
return false;
120+
if ((subnet == null || subnet.isInRange(remoteIp))
121+
&& FilenameUtils.directoryContains(rulePath, path)) {
122+
LOG.debug("Found matching rule, subnet: {}, path: {}; returned true",
123+
rule.getSubnet() != null ? subnet.getCidrSignature() : null,
124+
rulePath);
125+
return true;
131126
}
132127
}
133128

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/snapshot/TestSnapshot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public void testOfflineImageViewer() throws Exception {
257257
FSImageTestUtil.getFSImage(
258258
cluster.getNameNode()).getStorage().getStorageDir(0));
259259
assertNotNull("Didn't generate or can't find fsimage", originalFsimage);
260-
PrintStream o = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
260+
PrintStream o = new PrintStream(NullOutputStream.INSTANCE);
261261
PBImageXmlWriter v = new PBImageXmlWriter(new Configuration(), o);
262262
v.visit(new RandomAccessFile(originalFsimage, "r"));
263263
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ private static FileStatus pathToFileEntry(FileSystem hdfs, String file)
391391
@Test(expected = IOException.class)
392392
public void testTruncatedFSImage() throws IOException {
393393
File truncatedFile = new File(tempDir, "truncatedFsImage");
394-
PrintStream output = new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM);
394+
PrintStream output = new PrintStream(NullOutputStream.INSTANCE);
395395
copyPartOfFile(originalFsimage, truncatedFile);
396396
try (RandomAccessFile r = new RandomAccessFile(truncatedFile, "r")) {
397397
new FileDistributionCalculator(new Configuration(), 0, 0, false, output)

hadoop-project/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
<commons-collections.version>3.2.2</commons-collections.version>
128128
<commons-compress.version>1.24.0</commons-compress.version>
129129
<commons-csv.version>1.9.0</commons-csv.version>
130-
<commons-io.version>2.8.0</commons-io.version>
130+
<commons-io.version>2.14.0</commons-io.version>
131131
<commons-lang3.version>3.12.0</commons-lang3.version>
132132
<commons-logging.version>1.1.3</commons-logging.version>
133133
<commons-logging-api.version>1.1</commons-logging-api.version>

hadoop-tools/hadoop-archive-logs/src/main/java/org/apache/hadoop/tools/HadoopArchiveLogs.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
import java.io.File;
5656
import java.io.IOException;
57+
import java.nio.charset.StandardCharsets;
5758
import java.util.ArrayList;
5859
import java.util.Arrays;
5960
import java.util.Collections;
@@ -505,7 +506,10 @@ void generateScript(File localScript) throws IOException {
505506
String classpath = halrJarPath + File.pathSeparator + harJarPath;
506507
FileWriterWithEncoding fw = null;
507508
try {
508-
fw = new FileWriterWithEncoding(localScript, "UTF-8");
509+
fw = FileWriterWithEncoding.builder()
510+
.setFile(localScript)
511+
.setCharset(StandardCharsets.UTF_8)
512+
.get();
509513
fw.write("#!/bin/bash\nset -e\nset -x\n");
510514
int containerCount = 1;
511515
for (AppInfo context : eligibleApplications) {

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/services/TestTextFileBasedIdentityHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
package org.apache.hadoop.fs.azurebfs.services;
2020

2121
import java.io.File;
22-
import java.io.FileNotFoundException;
2322
import java.io.IOException;
2423
import java.nio.charset.Charset;
24+
import java.nio.file.NoSuchFileException;
2525

2626
import org.junit.Assert;
2727
import org.junit.BeforeClass;
@@ -114,7 +114,7 @@ public void testLookupForUser() throws IOException {
114114
public void testLookupForUserFileNotFound() throws Exception {
115115
TextFileBasedIdentityHandler handler =
116116
new TextFileBasedIdentityHandler(userMappingFile.getPath() + ".test", groupMappingFile.getPath());
117-
intercept(FileNotFoundException.class, "FileNotFoundException",
117+
intercept(NoSuchFileException.class, "NoSuchFileException",
118118
() -> handler.lookupForLocalUserIdentity(testUserDataLine3.split(":")[0]));
119119
}
120120

@@ -143,7 +143,7 @@ public void testLookupForGroup() throws IOException {
143143
public void testLookupForGroupFileNotFound() throws Exception {
144144
TextFileBasedIdentityHandler handler =
145145
new TextFileBasedIdentityHandler(userMappingFile.getPath(), groupMappingFile.getPath() + ".test");
146-
intercept(FileNotFoundException.class, "FileNotFoundException",
146+
intercept(NoSuchFileException.class, "NoSuchFileException",
147147
() -> handler.lookupForLocalGroupIdentity(testGroupDataLine2.split(":")[0]));
148148
}
149149
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/AggregatedLogFormat.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.io.PrintStream;
3333
import java.io.Writer;
3434
import java.nio.charset.Charset;
35+
import java.nio.charset.StandardCharsets;
3536
import java.security.PrivilegedExceptionAction;
3637
import java.util.ArrayList;
3738
import java.util.Arrays;
@@ -783,7 +784,10 @@ public static void readAcontainerLogs(DataInputStream valueStream,
783784
OutputStream os = null;
784785
PrintStream ps = null;
785786
try {
786-
os = new WriterOutputStream(writer, Charset.forName("UTF-8"));
787+
os = WriterOutputStream.builder()
788+
.setWriter(writer)
789+
.setCharset(StandardCharsets.UTF_8)
790+
.get();
787791
ps = new PrintStream(os);
788792
while (true) {
789793
try {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLeveldbTimelineStore.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,9 @@ public void testLevelDbRepair() throws IOException {
495495
store.init(conf);
496496
Mockito.verify(factory, Mockito.times(1))
497497
.repair(Mockito.any(File.class), Mockito.any(Options.class));
498-
FileFilter fileFilter = new WildcardFileFilter(
499-
"*" + LeveldbTimelineStore.BACKUP_EXT +"*");
498+
FileFilter fileFilter = WildcardFileFilter.builder()
499+
.setWildcards("*" + LeveldbTimelineStore.BACKUP_EXT +"*")
500+
.get();
500501
Assert.assertTrue(path.listFiles(fileFilter).length > 0);
501502
} finally {
502503
store.close();

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ public void testStorePerformance() throws IOException {
443443
store.init(conf);
444444
Mockito.verify(factory, Mockito.times(1))
445445
.repair(Mockito.any(File.class), Mockito.any(Options.class));
446-
FilenameFilter fileFilter =
447-
new WildcardFileFilter("*" + RollingLevelDBTimelineStore.BACKUP_EXT + "*");
446+
FilenameFilter fileFilter = WildcardFileFilter.builder()
447+
.setWildcards("*" + RollingLevelDBTimelineStore.BACKUP_EXT + "*")
448+
.get();
448449
Assert.assertTrue(new File(path.getAbsolutePath(), RollingLevelDBTimelineStore.FILENAME)
449450
.list(fileFilter).length > 0);
450451
} finally {

0 commit comments

Comments
 (0)