{"record":{"id":"2da7ee22950dfa61","repo":"openjdk/jdk","slug":"cannot-close-property-file","errorCode":null,"errorMessage":"cannot close property file","messagePattern":"cannot close property file","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"warning","filePath":"make/langtools/tools/anttasks/SelectToolTask.java","lineNumber":271,"sourceCode":"        return p;\n    }\n\n    Properties readProperties(File file) {\n        Properties p = new Properties();\n        if (file != null && file.exists()) {\n            Reader in = null;\n            try {\n                in = new BufferedReader(new FileReader(file));\n                p.load(in);\n                in.close();\n            } catch (IOException e) {\n                throw new BuildException(\"error reading property file\", e);\n            } finally {\n                if (in != null) {\n                    try {\n                        in.close();\n                    } catch (IOException e) {\n                        throw new BuildException(\"cannot close property file\", e);\n                    }\n                }\n            }\n        }\n        return p;\n    }\n\n    void writeProperties(File file, Properties p) {\n        if (file != null) {\n            Writer out = null;\n            try {\n                File dir = file.getParentFile();\n                if (dir != null && !dir.exists())\n                    dir.mkdirs();\n                out = new BufferedWriter(new FileWriter(file));\n                p.store(out, \"langtools properties\");\n                out.close();\n            } catch (IOException e) {","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/make/langtools/tools/anttasks/SelectToolTask.java#L253-L289","documentation":"Thrown from the finally block of SelectToolTask.readProperties when closing the BufferedReader fails with an IOException after the reader was successfully opened. This masks whatever happened in the try block (success or the 'error reading property file' path) because a throw in finally replaces it.","triggerScenarios":"The Reader was non-null (open succeeded or failed partway) and in.close() throws — typically when the underlying file descriptor became invalid (NFS dropout, file deleted mid-read).","commonSituations":"Flaky network filesystems; antivirus or mandatory-access-control systems closing handles; very rare on local disks.","solutions":["Re-run the task — transient close failures on local files essentially never repeat.","If persistent, inspect the cause chain and the filesystem health of the build directory.","Move the build tree off the flaky network mount."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// use try-with-resources so close failures surface as suppressed exceptions,\n// never masking the primary outcome\ntry (Reader in = new BufferedReader(new FileReader(file))) {\n    p.load(in);\n} catch (IOException e) {\n    throw new BuildException(\"error reading property file\", e);\n}","preventionTips":["Replace manual finally-close with try-with-resources everywhere in build tools.","Treat close-only failures as warnings in logs, not build-fatal errors, when the load already succeeded."],"tags":["ant","io","resource-close","finally"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}