quarkusio/quarkus · error · UncheckedIOException
Failed to hash content of
Error message
Failed to hash content of
What it means
ToolingUtils.sha1() streams a file through a SHA-1 MessageDigest to fingerprint local artifacts (with caching by path/mtime/size). If reading the file throws an IOException — file deleted between the exists() check and open, permission denied, or a filesystem/IO error — the IOException is wrapped in an UncheckedIOException so callers that handle only Unchecked exceptions are not forced to catch IOException. The message includes the file path being hashed.
Solutions
- Re-run the build — transient IO errors or races with a concurrent clean usually resolve on retry
- Verify the file exists and is readable by the Gradle daemon user (ls -l, check permissions/ACLs)
- Check the cause chain (e.getCause()) to distinguish FileNotFoundException (deleted/moved) from AccessDeniedException (permissions)
- Exclude conflicting concurrent tasks (clean running alongside quarkus tooling) or disable build caches that prune files mid-build
- Check disk/filesystem health if the error persists on different files
Example fix
// before (no guard)
String hash = ToolingUtils.hash(path);
// after (caller-side guard)
if (!Files.isReadable(path)) {
throw new IllegalStateException("Cannot read artifact for hashing: " + path);
}
try {
String hash = ToolingUtils.hash(path);
} catch (UncheckedIOException e) {
if (e.getCause() instanceof NoSuchFileException) {
hash = ToolingUtils.hash(path); // re-created after concurrent clean
} else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!Files.isReadable(file)) {
throw new IllegalStateException("Cannot hash unreadable file: " + file);
}
try (var in = Files.newInputStream(file)) { /* probe open */ } Try / catch
try {
String hash = ToolingUtils.hash(file);
} catch (UncheckedIOException e) {
if (e.getCause() instanceof NoSuchFileException || e.getCause() instanceof AccessDeniedException) {
// recover: re-check existence/permissions and retry once
} else throw new RuntimeException("Hashing failed for " + file, e);
} Prevention
- Verify file readability before hashing
- Avoid running clean tasks concurrently with Quarkus tooling tasks
- Watch the cause chain: NoSuchFileException vs AccessDeniedException point to different fixes
- Keep artifact caches on healthy local filesystems, not flaky network mounts
When it happens
Trigger: Calling ToolingUtils.hash(file) (via sha1) on a file that disappears mid-build (concurrent clean), on a file without read permission, or when the underlying filesystem fails during streaming (e.g. network mount dropped).
Common situations: Gradle daemon builds where a clean task or another process deletes a dependency JAR while Quarkus tooling hashes it; read-protected files under a user cache directory; NFS/overlayfs transient IO errors in CI containers.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Failed to load extension description
- Failed to load extension description + path
- Failed to collect project's classes in a temporary dir
- Failed to copy to
- Failed to create directories in
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1d4870c55aed76ed.
Report an issue: GitHub.
Appendix: source
Thrown at devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/ToolingUtils.java:283
return cached.hash();
}
final String hash = sha1(file);
DIGEST_CACHE.put(f.getAbsolutePath(), new FileDigest(lastModified, length, hash));
return hash;
}
/**
* Computes the hex-encoded SHA-1 of a file's content, streaming it without loading it into memory.
*/
private static String sha1(Path file) {
final MessageDigest digest = sha1Digest();
try (InputStream in = Files.newInputStream(file)) {
final byte[] buffer = new byte[8192];
for (int read = in.read(buffer); read >= 0; read = in.read(buffer)) {
digest.update(buffer, 0, read);
}
} catch (IOException e) {
throw new UncheckedIOException("Failed to hash content of " + file, e);
}
return HexFormat.of().formatHex(digest.digest());
}
private static MessageDigest sha1Digest() {
try {
return MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
}
View on GitHub (pinned to e1c734241f)