{"record":{"id":"60c1a96052d7997e","repo":"apache/hadoop","slug":"rename-destination-directory-is-not-empty","errorCode":null,"errorMessage":"rename destination directory is not empty: {}","messagePattern":"rename destination directory is not empty: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java","lineNumber":592,"sourceCode":"          + \" must both be directories\";\n      NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n          + error);\n      throw new IOException(error);\n    }\n    if (!overwrite) { // If destination exists, overwrite flag must be true\n      error = \"rename destination \" + dst + \" already exists\";\n      NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n          + error);\n      throw new FileAlreadyExistsException(error);\n    }\n    if (dstInode.isDirectory()) {\n      final ReadOnlyList<INode> children = dstInode.asDirectory()\n          .getChildrenList(Snapshot.CURRENT_STATE_ID);\n      if (!children.isEmpty()) {\n        error = \"rename destination directory is not empty: \" + dst;\n        NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n            + error);\n        throw new IOException(error);\n      }\n    }\n  }\n\n  private static void validateRenameSource(FSDirectory fsd,\n      INodesInPath srcIIP, List<INodeDirectory> snapshottableDirs)\n      throws IOException {\n    String error;\n    final INode srcInode = srcIIP.getLastINode();\n    // validate source\n    if (srcInode == null) {\n      error = \"rename source \" + srcIIP.getPath() + \" is not found.\";\n      NameNode.stateChangeLog.warn(\"DIR* FSDirectory.unprotectedRenameTo: \"\n          + error);\n      throw new FileNotFoundException(error);\n    }\n    if (srcIIP.length() == 1) {\n      error = \"rename source cannot be the root\";","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java#L574-L610","documentation":"Error \"rename destination directory is not empty: {}\" thrown in apache/hadoop.","triggerScenarios":"Renaming (with overwrite semantics) a directory onto an existing destination directory that still contains entries.","commonSituations":"See trigger scenarios.","solutions":["Delete the contents of the destination directory before renaming onto it.","Pick an empty or non-existing destination directory."],"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"}