{"record":{"id":"b0c3c57e2b48d235","repo":"apache/hadoop","slug":"failed-to-rename-s-to-s-file-already-exists-or","errorCode":null,"errorMessage":"Failed to rename %s to %s, file already exists or not empty!","messagePattern":"Failed to rename (.+?) to (.+?), file already exists or not empty!","errorType":"exception","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java","lineNumber":804,"sourceCode":"      LOG.debug(\"Parent directory {} does not exist \"\n          + \"or will be implicitly created during rename\",\n          dstPath.getParent());\n    } else {\n      if (dstStatus.isDirectory()) {\n        dstPath = new Path(dstPath, srcPath.getName());\n        FileStatus status;\n        try {\n          status = getFileStatus(dstPath);\n        } catch (FileNotFoundException fnde) {\n          status = null;\n        }\n        if (status != null) {\n          if (status.isFile()) {\n            LOG.debug(\"Deleting existing destination \"\n                + \"file {} before rename\", dstPath);\n            delete(dstPath, false);\n          } else {\n            throw new FileAlreadyExistsException(\n                String.format(\n                    \"Failed to rename %s to %s, \"\n                        + \"file already exists or not empty!\",\n                    srcPath, dstPath));\n          }\n        }\n      } else {\n        LOG.debug(\"Deleting existing destination \"\n            + \"file {} before rename\", dstPath);\n        delete(dstPath, false);\n      }\n    }\n\n    store.rename(pathToKey(srcPath), pathToKey(dstPath),\n        srcStatus.isFile());\n    return true;\n  }\n","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BaiduBosFileSystem.java#L786-L822","documentation":"The primary ZombieJob constructor requires a non-null LoggedJob and throws IllegalArgumentException('job is null') otherwise. A ZombieJob is a simulated reincarnation of one specific dead job; without the logged job record there is nothing to simulate, so the guard fails fast. Because LoggedJob normally comes from deserializing a rumen JSON trace, a null usually means the trace lookup returned nothing rather than a caller explicitly passing null.","triggerScenarios":"new ZombieJob(null, cluster, seed) or new ZombieJob(null, cluster); looking up a job in a trace by name/id, getting null back (job not found), and passing it straight to the constructor; JSON deserialization returning null for an absent record.","commonSituations":"Trace-driven simulators (Mumak) loading a job trace where the requested job index/id does not exist; empty or truncated rumen trace files; a Map over trace entries where a filter/null creeps in.","solutions":["Null-check the LoggedJob obtained from the trace before constructing the ZombieJob and handle 'not found' explicitly (skip, or fail with your own contextual message).","Validate the trace file is a real rumen JSON trace and actually contains the job you are looking for (inspect the top-level array/object).","If you need a synthetic job without logged data, ZombieJob is the wrong tool — construct LoggedJob with minimal fields rather than passing null."],"exampleFix":"// before\nLoggedJob job = getJobByName(trace, jobName); // returns null when absent\nJobStory story = new ZombieJob(job, cluster); // IllegalArgumentException\n\n// after\nLoggedJob job = getJobByName(trace, jobName);\nif (job == null) {\n  throw new IOException(\"Job '\" + jobName + \"' not found in trace \" + tracePath);\n}\nJobStory story = new ZombieJob(job, cluster);","handlingStrategy":"validation","validationCode":"static ZombieJob newZombieJob(LoggedJob job, ClusterStory cluster, long seed) {\n  if (job == null) {\n    throw new NoSuchElementException(\n        \"No logged job to simulate; check the trace lookup\");\n  }\n  return new ZombieJob(job, cluster, seed);\n}","typeGuard":"static boolean hasLoggedJob(LoggedJob job) {\n  return job != null;\n}","tryCatchPattern":null,"preventionTips":["Null-check every LoggedJob obtained from trace lookups before constructing ZombieJob.","Validate that the trace file is non-empty and contains the target job before replay loops.","Distinguish 'job absent' (your error with context) from rumen's generic 'job is null'."],"tags":["hadoop","rumen","null-check","job-trace","constructor-validation"],"backgroundTag":"null-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}