{"record":{"id":"b28d67e47db79431","repo":"prestodb/presto","slug":"java-io-ioexception-wrapped-in-uncheckedioexcepti-b28d67","errorCode":null,"errorMessage":"java.io.IOException (wrapped in UncheckedIOException)","messagePattern":"java\\.io\\.IOException \\(wrapped in UncheckedIOException\\)","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"warning","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/MapBatchStreamReader.java","lineNumber":113,"sourceCode":"    }\n\n    @Override\n    public String toString()\n    {\n        return toStringHelper(this)\n                .addValue(streamDescriptor)\n                .toString();\n    }\n\n    @Override\n    public void close()\n    {\n        try (Closer closer = Closer.create()) {\n            closer.register(directReader::close);\n            closer.register(flatReader::close);\n        }\n        catch (IOException e) {\n            throw new UncheckedIOException(e);\n        }\n    }\n\n    @Override\n    public long getRetainedSizeInBytes()\n    {\n        return INSTANCE_SIZE + directReader.getRetainedSizeInBytes() + flatReader.getRetainedSizeInBytes();\n    }\n}\n","sourceCodeStart":95,"sourceCodeEnd":123,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/MapBatchStreamReader.java#L95-L123","documentation":"MapBatchStreamReader.close wraps IOException raised while closing its direct/flat delegate readers in UncheckedIOException. It is a cleanup-time failure: closing the child map readers (and their nested key/value streams) hit an I/O problem, typically because the underlying source was already closed or a storage error occurred.","triggerScenarios":"Calling close() after the OrcDataSource has already been closed elsewhere; storage-layer failure during stream teardown of key/value sub-readers.","commonSituations":"Query cancellation paths that close the datasource before page-source readers; double-close in custom readers; transient HDFS/S3 errors during teardown.","solutions":["Ensure the OrcDataSource outlives all readers; close readers first, source last.","Make close() idempotent in any custom stream implementations.","Inspect the wrapped cause — treat this as secondary to the original query failure.","Upgrade if the unwrap reveals a known double-close issue in the ORC driver."],"exampleFix":"// before\ndataSource.close();\nmapReader.close();\n// after\nmapReader.close();\ndataSource.close();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mapReader.close();\n}\ncatch (UncheckedIOException e) {\n    LOG.warn(e.getCause(), \"Failed to close map batch reader delegates\");\n}","preventionTips":["Close readers before closing the OrcDataSource.","Use Closer.create() so all delegates still get closed even if one throws.","Keep the datasource open until all page sources are drained or cancelled.","Make close() idempotent in custom streams."],"tags":["io","resource-cleanup","orc","map"],"backgroundTag":"unchecked-io-exception","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}