apache/hadoop · error · PathIOException
Not a zero-length file
Error message
Not a zero-length file
What it means
Error "Not a zero-length file" thrown in apache/hadoop.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/TouchCommands.java:74
public static final String DESCRIPTION =
"Creates a file of zero length " +
"at <path> with current time as the timestamp of that <path>. " +
"An error is returned if the file exists with non-zero length\n";
@Override
protected void processOptions(LinkedList<String> args) {
CommandFormat cf = new CommandFormat(1, Integer.MAX_VALUE);
cf.parse(args);
}
@Override
protected void processPath(PathData item) throws IOException {
if (item.stat.isDirectory()) {
// TODO: handle this
throw new PathIsDirectoryException(item.toString());
}
if (item.stat.getLen() != 0) {
throw new PathIOException(item.toString(), "Not a zero-length file");
}
touchz(item);
}
@Override
protected void processNonexistentPath(PathData item) throws IOException {
if (!item.parentExists()) {
throw new PathNotFoundException(item.toString())
.withFullyQualifiedPath(item.path.toUri().toString());
}
touchz(item);
}
private void touchz(PathData item) throws IOException {
item.fs.create(item.path).close();
}
}
View on GitHub (pinned to 2add963021)
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.
When it happens
Trigger: Thrown by the touchz shell command when the target path exists and is not a zero-length file.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/fa69c9da2919280f.
Report an issue: GitHub.