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 su...@apache.org on 2021/09/26 05:10:13 UTC

[hadoop] 02/02: Revert "HADOOP-16878. FileUtil.copy() to throw IOException if the source and destination are the same"

This is an automated email from the ASF dual-hosted git repository.

sunchao pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit 1397cf24966cd98a74a94d37aaa9a09ba2aa7967
Author: Chao Sun <su...@apache.org>
AuthorDate: Sat Sep 25 21:32:43 2021 -0700

    Revert "HADOOP-16878. FileUtil.copy() to throw IOException if the source and destination are the same"
    
    This reverts commit 59f01a548e457a535aa8b5035142c9fbdc34b5b4.
---
 .../src/main/java/org/apache/hadoop/fs/FileUtil.java     |  6 ------
 .../test/java/org/apache/hadoop/fs/TestFsShellCopy.java  | 16 +---------------
 .../apache/hadoop/hdfs/TestDistributedFileSystem.java    | 16 ----------------
 3 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
index d0a66be..3c88e5d 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
@@ -399,12 +399,6 @@ public class FileUtil {
                              Configuration conf) throws IOException {
     Path src = srcStatus.getPath();
     dst = checkDest(src.getName(), dstFS, dst, overwrite);
-
-    if (srcFS.makeQualified(src).equals(dstFS.makeQualified(dst))) {
-      throw new PathOperationException("Source (" + src + ") and destination " +
-          "(" + dst + ") are equal in the copy command.");
-    }
-
     if (srcStatus.isDirectory()) {
       checkDependencies(srcFS, src, dstFS, dst);
       if (!dstFS.mkdirs(dst)) {
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java
index 62c1b73..7556bc7 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java
@@ -33,7 +33,6 @@ import java.io.PrintStream;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.apache.hadoop.test.LambdaTestUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -175,20 +174,7 @@ public class TestFsShellCopy {
     checkPut(dirPath, targetDir, true);
   }
 
-  @Test
-  public void testCopyBetweenFsEqualPath() throws Exception {
-    Path testRoot = new Path(testRootDir, "testPutFile");
-    lfs.delete(testRoot, true);
-    lfs.mkdirs(testRoot);
-
-    Path filePath = new Path(testRoot, "sameSourceTarget");
-    lfs.create(filePath).close();
-    final FileStatus status = lfs.getFileStatus(filePath);
-    LambdaTestUtils.intercept(PathOperationException.class, () ->
-        FileUtil.copy(lfs, status, lfs, filePath, false, true, conf)
-    );
-  }
-
+  
   private void checkPut(Path srcPath, Path targetDir, boolean useWindowsPath)
   throws Exception {
     lfs.delete(targetDir, true);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
index f7dcaef..32b09926 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java
@@ -69,7 +69,6 @@ import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FileSystem.Statistics.StatisticsData;
-import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.fs.FsServerDefaults;
 import org.apache.hadoop.fs.FileChecksum;
 import org.apache.hadoop.fs.FileStatus;
@@ -80,7 +79,6 @@ import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
-import org.apache.hadoop.fs.PathOperationException;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.fs.StorageStatistics.LongStatistic;
 import org.apache.hadoop.fs.StorageType;
@@ -2502,20 +2500,6 @@ public class TestDistributedFileSystem {
   }
 
   @Test
-  public void testCopyBetweenFsEqualPath() throws Exception {
-    Configuration conf = getTestConfiguration();
-    try (MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()) {
-      cluster.waitActive();
-      final DistributedFileSystem dfs = cluster.getFileSystem();
-      Path filePath = new Path("/dir/file");
-      dfs.create(filePath).close();
-      FileStatus fstatus = dfs.getFileStatus(filePath);
-      LambdaTestUtils.intercept(PathOperationException.class,
-          () -> FileUtil.copy(dfs, fstatus, dfs, filePath, false, true, conf));
-    }
-  }
-
-  @Test
   public void testNameNodeCreateSnapshotTrashRootOnStartup()
       throws Exception {
     // Start NN with dfs.namenode.snapshot.trashroot.enabled=false

---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org