{"record":{"id":"fa69c9da2919280f","repo":"apache/hadoop","slug":"not-a-zero-length-file","errorCode":null,"errorMessage":"Not a zero-length file","messagePattern":"Not a zero-length file","errorType":"exception","errorClass":"PathIOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/TouchCommands.java","lineNumber":74,"sourceCode":"    public static final String DESCRIPTION =\n      \"Creates a file of zero length \" +\n      \"at <path> with current time as the timestamp of that <path>. \" +\n      \"An error is returned if the file exists with non-zero length\\n\";\n\n    @Override\n    protected void processOptions(LinkedList<String> args) {\n      CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE);\n      cf.parse(args);\n    }\n\n    @Override\n    protected void processPath(PathData item) throws IOException {\n      if (item.stat.isDirectory()) {\n        // TODO: handle this\n        throw new PathIsDirectoryException(item.toString());\n      }\n      if (item.stat.getLen() != 0) {\n        throw new PathIOException(item.toString(), \"Not a zero-length file\");\n      }\n      touchz(item);\n    }\n\n    @Override\n    protected void processNonexistentPath(PathData item) throws IOException {\n      if (!item.parentExists()) {\n        throw new PathNotFoundException(item.toString())\n            .withFullyQualifiedPath(item.path.toUri().toString());\n      }\n      touchz(item);\n    }\n\n    private void touchz(PathData item) throws IOException {\n      item.fs.create(item.path).close();\n    }\n  }\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/TouchCommands.java#L56-L92","documentation":"Error \"Not a zero-length file\" thrown in apache/hadoop.","triggerScenarios":"Thrown by the touchz shell command when the target path exists and is not a zero-length file.","commonSituations":"See trigger scenarios.","solutions":["Use -touchz only to create zero-length files; the target exists and is not empty.","Use touch (without -z) to update timestamps of non-empty files."],"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"}