openjdk/jdk · warning · BuildException

cannot close property file

Error message

cannot close property file

What it means

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.

Source

Thrown at make/langtools/tools/anttasks/SelectToolTask.java:271

        return p;
    }

    Properties readProperties(File file) {
        Properties p = new Properties();
        if (file != null && file.exists()) {
            Reader in = null;
            try {
                in = new BufferedReader(new FileReader(file));
                p.load(in);
                in.close();
            } catch (IOException e) {
                throw new BuildException("error reading property file", e);
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                        throw new BuildException("cannot close property file", e);
                    }
                }
            }
        }
        return p;
    }

    void writeProperties(File file, Properties p) {
        if (file != null) {
            Writer out = null;
            try {
                File dir = file.getParentFile();
                if (dir != null && !dir.exists())
                    dir.mkdirs();
                out = new BufferedWriter(new FileWriter(file));
                p.store(out, "langtools properties");
                out.close();
            } catch (IOException e) {

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Re-run the task — transient close failures on local files essentially never repeat.
  2. If persistent, inspect the cause chain and the filesystem health of the build directory.
  3. Move the build tree off the flaky network mount.
Defensive patterns

Strategy: try-catch

Try / catch

// use try-with-resources so close failures surface as suppressed exceptions,
// never masking the primary outcome
try (Reader in = new BufferedReader(new FileReader(file))) {
    p.load(in);
} catch (IOException e) {
    throw new BuildException("error reading property file", e);
}

Prevention

When it happens

Trigger: 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).

Common situations: Flaky network filesystems; antivirus or mandatory-access-control systems closing handles; very rare on local disks.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/2da7ee22950dfa61. Report an issue: GitHub.