{"record":{"id":"1261f7f28b75c9bf","repo":"apache/hadoop","slug":"directory-s-is-not-empty","errorCode":null,"errorMessage":"Directory: %s is not empty.","messagePattern":"Directory: (.+?) is not empty\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java","lineNumber":400,"sourceCode":"      fileStat = getFileStatus(channel, absolute);\n    } catch (FileNotFoundException e) {\n      // file not found, no need to delete, return true\n      return false;\n    }\n    if (!fileStat.isDirectory()) {\n      boolean status = true;\n      try {\n        channel.rm(pathName);\n      } catch (SftpException e) {\n        status = false;\n      }\n      return status;\n    } else {\n      boolean status = true;\n      FileStatus[] dirEntries = listStatus(channel, absolute);\n      if (dirEntries != null && dirEntries.length > 0) {\n        if (!recursive) {\n          throw new IOException(String.format(E_DIR_NOTEMPTY, file));\n        }\n        for (int i = 0; i < dirEntries.length; ++i) {\n          delete(channel, new Path(absolute, dirEntries[i].getPath()),\n              recursive);\n        }\n      }\n      try {\n        channel.rmdir(pathName);\n      } catch (SftpException e) {\n        status = false;\n      }\n      return status;\n    }\n  }\n\n  /**\n   * Convenience method, so that we don't open a new connection when using this\n   * method from within another method. Otherwise every API invocation incurs","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/sftp/SFTPFileSystem.java#L382-L418","documentation":"Error \"Directory: %s is not empty.\" thrown in apache/hadoop.","triggerScenarios":"Thrown by SFTPFileSystem.delete when asked to delete a directory non-recursively while it still contains entries.","commonSituations":"See trigger scenarios.","solutions":["Delete the directory contents first, or use recursive delete (delete(path, true)).","Verify the directory is empty on the SFTP server before non-recursive deletion."],"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"}