{"record":{"id":"be26657e2bee4879","repo":"apache/hadoop","slug":"cannot-copy-to-itself","errorCode":null,"errorMessage":"Cannot copy {} to itself.","messagePattern":"Cannot copy (.+?) to itself\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java","lineNumber":346,"sourceCode":"  throws IOException {\n    fs.delete(dir, true);\n  }\n\n  //\n  // If the destination is a subdirectory of the source, then\n  // generate exception\n  //\n  private static void checkDependencies(FileSystem srcFS,\n                                        Path src,\n                                        FileSystem dstFS,\n                                        Path dst)\n                                        throws IOException {\n    if (srcFS == dstFS) {\n      String srcq = srcFS.makeQualified(src).toString() + Path.SEPARATOR;\n      String dstq = dstFS.makeQualified(dst).toString() + Path.SEPARATOR;\n      if (dstq.startsWith(srcq)) {\n        if (srcq.length() == dstq.length()) {\n          throw new IOException(\"Cannot copy \" + src + \" to itself.\");\n        } else {\n          throw new IOException(\"Cannot copy \" + src + \" to its subdirectory \" +\n                                dst);\n        }\n      }\n    }\n  }\n\n  /**\n   * Copy files between FileSystems.\n   * @param srcFS src fs.\n   * @param src src.\n   * @param dstFS dst fs.\n   * @param dst dst.\n   * @param deleteSource delete source.\n   * @param conf configuration.\n   * @return if copy success true, not false.\n   * @throws IOException raised on errors performing I/O.","sourceCodeStart":328,"sourceCodeEnd":364,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java#L328-L364","documentation":"Error \"Cannot copy {} to itself.\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java:346 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a destination different from the source path.","Check for path canonicalization issues that make distinct paths resolve to the same file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}