{"record":{"id":"8fbaad4f8fec8af0","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-delete-jar-files-from-working-directory-8fbaad","errorCode":null,"errorMessage":"Failed to delete JAR files from working directory","messagePattern":"Failed to delete JAR files from working directory","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/utils/FileUtils.java","lineNumber":169,"sourceCode":"\t */\n\tpublic static void deleteResourceJarFromWorkDir(String workDir) {\n\t\ttry {\n\t\t\tPath workDirPath = Path.of(workDir);\n\t\t\tif (Files.exists(workDirPath)) {\n\t\t\t\ttry (var stream = Files.walk(workDirPath)) {\n\t\t\t\t\tstream.filter(path -> path.toString().endsWith(\".jar\")).forEach(jarPath -> {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tFiles.deleteIfExists(jarPath);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (IOException e) {\n\t\t\t\t\t\t\tthrow new RuntimeException(\"Failed to delete JAR file: \" + jarPath, e);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new RuntimeException(\"Failed to delete JAR files from working directory\", e);\n\t\t}\n\t}\n\n}\n","sourceCodeStart":151,"sourceCodeEnd":174,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/utils/FileUtils.java#L151-L174","documentation":"Outer wrapper thrown by FileUtils.deleteResourceJarFromWorkDir when the Files.walk over the working directory itself fails with an IOException. It means the cleanup could not even enumerate the JAR files, e.g. because the directory does not exist or is unreadable.","triggerScenarios":"Files.walk(workDirPath) throws IOException — the working directory was removed concurrently, the path is not a directory, or the filesystem is inaccessible/unreadable.","commonSituations":"Calling cleanup before copyResourceJarToWorkDir ever created the directory; container volumes unmounted mid-run; permission changes on shared working directories.","solutions":["Check that the working directory exists and is readable before calling cleanup.","Inspect the wrapped IOException cause for the exact filesystem error.","Guard the call with a directory-existence check or treat 'no directory' as a no-op.","Fix permissions on the working directory or point cleanup at the correct path."],"exampleFix":"// before: cleanup assumes dir exists\nFileUtils.deleteResourceJarFromWorkDir();\n// after: no-op when the dir is absent\nPath workDir = Path.of(workDirPath);\nif (Files.isDirectory(workDir)) {\n    FileUtils.deleteResourceJarFromWorkDir();\n}","handlingStrategy":"fallback","validationCode":"Path workDir = Path.of(workDirPath);\nif (!Files.isDirectory(workDir)) {\n    logger.info(\"Work dir {} absent; skipping cleanup\", workDir);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    FileUtils.deleteResourceJarFromWorkDir();\n} catch (RuntimeException e) {\n    logger.warn(\"Cleanup skipped (walk failed): {}\", e.getCause() != null ? e.getCause().getMessage() : e.getMessage());\n}","preventionTips":["Treat missing/unreadable working directory as a no-op cleanup.","Confirm the directory path is correct and mounted before calling cleanup.","Don't delete the working directory concurrently with cleanup."],"tags":["filesystem","io","directory","cleanup"],"backgroundTag":"directory-not-found","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}