diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 4ffa26b7a84..dcc8f5bde61 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -565,6 +565,9 @@ Release 2.3.0 - UNRELEASED HADOOP-10087. UserGroupInformation.getGroupNames() fails to return primary group first when JniBasedUnixGroupsMappingWithFallback is used (cmccabe) + HADOOP-10175. Har files system authority should preserve userinfo. + (Chuan Liu via cnauroth) + Release 2.2.0 - 2013-10-13 INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java index 091b35a846a..88208da651a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java @@ -294,6 +294,10 @@ public class HarFileSystem extends FileSystem { private String getHarAuth(URI underLyingUri) { String auth = underLyingUri.getScheme() + "-"; if (underLyingUri.getHost() != null) { + if (underLyingUri.getUserInfo() != null) { + auth += underLyingUri.getUserInfo(); + auth += "@"; + } auth += underLyingUri.getHost(); if (underLyingUri.getPort() != -1) { auth += ":"; diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java index 237d7161f72..577abfd090e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java @@ -258,6 +258,22 @@ public class TestHarFileSystemBasics { 0, expectedFileNames.size()); } + @Test + public void testMakeQualifiedPath() throws Exception { + // Construct a valid har file system path with authority that + // contains userinfo and port. The userinfo and port are useless + // in local fs uri. They are only used to verify har file system + // can correctly preserve the information for the underlying file system. + String harPathWithUserinfo = "har://file-user:passwd@localhost:80" + + harPath.toUri().getPath().toString(); + Path path = new Path(harPathWithUserinfo); + Path qualifiedPath = path.getFileSystem(conf).makeQualified(path); + assertTrue(String.format( + "The qualified path (%s) did not match the expected path (%s).", + qualifiedPath.toString(), harPathWithUserinfo), + qualifiedPath.toString().equals(harPathWithUserinfo)); + } + // ========== Negative: @Test