{"record":{"id":"210ccc3b0b40dcfa","repo":"apache/cassandra","slug":"failed-closing-210ccc","errorCode":null,"errorMessage":"Failed closing {}","messagePattern":"Failed closing (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/io/util/FileUtils.java","lineNumber":253,"sourceCode":"        {\n            channel.truncate(size);\n        }\n        catch (IOException e)\n        {\n            throw PathUtils.propagateUnchecked(e, file.toPath(), true);\n        }\n    }\n\n    public static void closeQuietly(Closeable c)\n    {\n        try\n        {\n            if (c != null)\n                c.close();\n        }\n        catch (Exception e)\n        {\n            logger.warn(\"Failed closing {}\", c, e);\n        }\n    }\n\n    public static void closeQuietly(AutoCloseable c)\n    {\n        try\n        {\n            if (c != null)\n                c.close();\n        }\n        catch (Exception e)\n        {\n            logger.warn(\"Failed closing {}\", c, e);\n        }\n    }\n\n    public static void close(Closeable... cs) throws IOException\n    {","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/util/FileUtils.java#L235-L271","documentation":"FileUtils.closeQuietly(Closeable) swallows any exception thrown while closing a stream or channel, logging a warning with the object that failed to close. The operation continues because close failures during cleanup are usually non-fatal.","triggerScenarios":"Any code path calling FileUtils.closeQuietly(...) where the underlying close() throws (e.g. IOException flushing buffered data, already-closed stream, disk I/O error on close).","commonSituations":"Disk-full conditions while flushing a compaction writer; interrupted or failed sstable writes being cleaned up; double-close of a stream.","solutions":["Check the log for the preceding root cause (often disk full or I/O error) and fix that first","Ensure resources are closed once via try-with-resources instead of manual close","Verify filesystem health (dmesg, df) if close failures recur","If data loss is a concern, re-run the operation (compaction, streaming) that owned the resource"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    FileUtils.closeQuietly(stream);\n} catch (Throwable t) { /* closeQuietly never throws; rely on its warn log for diagnosis */ }\n// For resources whose close errors matter:\ntry { stream.close(); } catch (IOException e) { handle(e); }","preventionTips":["Use try-with-resources for resources where close errors are meaningful","Monitor disks for ENOSPC, the most common cause of close failures","Avoid double-closing streams","Check node logs for the underlying I/O cause"],"tags":["io","resource-cleanup","close"],"backgroundTag":"file-close-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}