You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ge...@apache.org on 2015/03/10 22:07:54 UTC

hadoop git commit: DelegateToFileSystem erroneously uses default FS's port in constructor. (Brahma Reddy Battula via gera)

Repository: hadoop
Updated Branches:
  refs/heads/trunk aa92b764a -> 64eb068ee


DelegateToFileSystem erroneously uses default FS's port in constructor. (Brahma Reddy Battula via gera)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/64eb068e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/64eb068e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/64eb068e

Branch: refs/heads/trunk
Commit: 64eb068ee8863da41df8db44bde1a9033198983d
Parents: aa92b76
Author: Gera Shegalov <ge...@apache.org>
Authored: Tue Mar 10 13:52:06 2015 -0700
Committer: Gera Shegalov <ge...@apache.org>
Committed: Tue Mar 10 13:52:06 2015 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt |  3 ++
 .../apache/hadoop/fs/DelegateToFileSystem.java  |  3 +-
 .../src/main/resources/core-default.xml         |  6 +++
 .../hadoop/fs/TestDelegateToFileSystem.java     | 52 ++++++++++++++++++++
 4 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/64eb068e/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index ab58270..3e42aa8 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -1082,6 +1082,9 @@ Release 2.7.0 - UNRELEASED
     HADOOP-11692. Improve authentication failure WARN message to avoid user
     confusion. (Yongjun Zhang)
 
+    HADOOP-11618. DelegateToFileSystem erroneously uses default FS's port in
+    constructor. (Brahma Reddy Battula via gera)
+
 Release 2.6.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/64eb068e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
index 09707c6..6b7f387 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DelegateToFileSystem.java
@@ -29,7 +29,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.util.Progressable;
@@ -47,7 +46,7 @@ public abstract class DelegateToFileSystem extends AbstractFileSystem {
       Configuration conf, String supportedScheme, boolean authorityRequired)
       throws IOException, URISyntaxException {
     super(theUri, supportedScheme, authorityRequired, 
-        FileSystem.getDefaultUri(conf).getPort());
+        theFsImpl.getDefaultPort());
     fsImpl = theFsImpl;
     fsImpl.initialize(theUri, conf);
     fsImpl.statistics = getStatistics();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/64eb068e/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml
index 1d531df..46eae0a 100644
--- a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml
+++ b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml
@@ -581,6 +581,12 @@ for ldap providers in the same way as above does.
 </property>
 
 <property>
+  <name>fs.AbstractFileSystem.ftp.impl</name>
+  <value>org.apache.hadoop.fs.ftp.FtpFs</value>
+  <description>The FileSystem for Ftp: uris.</description>
+</property>
+
+<property>
   <name>fs.ftp.host</name>
   <value>0.0.0.0</value>
   <description>FTP filesystem connects to this server</description>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/64eb068e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java
new file mode 100644
index 0000000..5de3286
--- /dev/null
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.fs;
+
+import java.net.URI;
+
+import org.apache.commons.net.ftp.FTP;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestDelegateToFileSystem {
+
+  private static final String FTP_DUMMYHOST = "ftp://dummyhost";
+  private static final URI FTP_URI_NO_PORT = URI.create(FTP_DUMMYHOST);
+  private static final URI FTP_URI_WITH_PORT = URI.create(FTP_DUMMYHOST + ":"
+      + FTP.DEFAULT_PORT);
+
+  private void testDefaultUriInternal(String defaultUri)
+      throws UnsupportedFileSystemException {
+    final Configuration conf = new Configuration();
+    FileSystem.setDefaultUri(conf, defaultUri);
+    final AbstractFileSystem ftpFs =
+        AbstractFileSystem.get(FTP_URI_NO_PORT, conf);
+    Assert.assertEquals(FTP_URI_WITH_PORT, ftpFs.getUri());
+  }
+
+  @Test
+  public void testDefaultURIwithOutPort() throws Exception {
+    testDefaultUriInternal("hdfs://dummyhost");
+  }
+
+  @Test
+  public void testDefaultURIwithPort() throws Exception {
+    testDefaultUriInternal("hdfs://dummyhost:8020");
+  }
+}