{"record":{"id":"9b90a02f50a2bb63","repo":"quarkusio/quarkus","slug":"failed-to-get-source-file-mtime-for","errorCode":null,"errorMessage":"Failed to get source file mtime for ","messagePattern":"Failed to get source file mtime for ","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/util/CustomFileSystemOperations.java","lineNumber":97,"sourceCode":"\n        public TimestampPreservingCopyAction(Path srcDir, Path destDir, List<CopiedFileMetadata> processedFiles) {\n            this.srcDir = srcDir;\n            this.destDir = destDir;\n            this.processedFiles = processedFiles;\n        }\n\n        @Override\n        public void execute(FileCopyDetails details) {\n            // Capture source file timestamp for later restoration.\n            // Also delete any pre-existing non-writeable destination file to prevent copy failures.\n            // This occurs with read-only files like 'app-cds.jsa' which should remain read-only.\n\n            FileTime sourceMtime;\n            Path sourceFile = srcDir.resolve(details.getSourcePath());\n            try {\n                sourceMtime = Files.getLastModifiedTime(sourceFile);\n            } catch (IOException e) {\n                throw new GradleException(\"Failed to get source file mtime for \" + details.getSourcePath(), e);\n            }\n            Path destFile = destDir.resolve(details.getPath());\n            if (Files.exists(destFile) && !Files.isWritable(destFile)) {\n                deleteFileIfExists(destFile);\n            }\n            processedFiles.add(new CopiedFileMetadata(sourceFile, destFile, sourceMtime));\n        }\n    }\n\n    private record CopiedFileMetadata(Path source, Path destination, FileTime sourceMtime) {\n    }\n\n    /**\n     * Copies files while preserving their original timestamps.\n     *\n     * @param customizer configuration customizer\n     * @return the result of the copy operation\n     */","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/util/CustomFileSystemOperations.java#L79-L115","documentation":"CustomFileSystemOperations.execute (used by Quarkus' timestamp-preserving copy action) resolves each source file and reads its last-modified time via Files.getLastModifiedTime. On IOException it throws GradleException 'Failed to get source file mtime for <sourcePath>'. This metadata is needed to preserve modification timestamps on copied files.","triggerScenarios":"Running a Quarkus Gradle task that copies files with the custom copy/sync configuration when the source file cannot be stat'd: the source file was deleted or renamed between listing and copying (race with concurrent task or clean), or an I/O permission error occurs reading the attribute.","commonSituations":"Parallel Gradle tasks or external processes (clean, IDE sync) deleting files mid-copy; symlinked or special files in srcDir; permission-restricted source directories; network filesystems flaking on attribute reads.","solutions":["Re-run the build — a transient race (file deleted mid-copy) usually resolves on a clean retry.","Ensure no concurrent task/process deletes the source directory while copying (avoid running clean in parallel).","Check read permissions on the source directory and files.","Replace broken symlinks or remove special files from the source directory."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"File srcDir = ...;\nif (!srcDir.canRead()) throw new IllegalStateException(\"source dir unreadable: \" + srcDir);\n// avoid concurrent clean while copy tasks run: use --no-parallel and don't run clean concurrently","typeGuard":null,"tryCatchPattern":"try {\n    ./gradlew build\n} catch (GradleException e) {\n    if (e.getMessage().startsWith(\"Failed to get source file mtime for\")) {\n        // transient race — stop other build processes and retry\n    }\n}","preventionTips":["Don't run gradle clean concurrently with build tasks","Exclude source and build dirs from external processes that delete/move files","Ensure read permissions on source directories in CI containers","Retry transient filesystem races on network mounts"],"tags":["gradle","io","filesystem","copy"],"backgroundTag":"file-read-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}