{"record":{"id":"a0d372e9c0120902","repo":"prestodb/presto","slug":"java-io-ioexception-wrapped-in-uncheckedioexcepti-a0d372","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/MapDirectBatchStreamReader.java","lineNumber":285,"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(keyStreamReader::close);\n            closer.register(valueStreamReader::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 + keyStreamReader.getRetainedSizeInBytes() + valueStreamReader.getRetainedSizeInBytes();\n    }\n}\n","sourceCodeStart":267,"sourceCodeEnd":295,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/MapDirectBatchStreamReader.java#L267-L295","documentation":"MapDirectBatchStreamReader.close wraps IOException from closing the nested key and value stream readers in UncheckedIOException. It is a teardown-time failure indicating the underlying ORC streams could not be closed cleanly — typically because the datasource was already closed or a storage error occurred during cleanup.","triggerScenarios":"Calling close() on the map reader after the OrcDataSource was closed; disk/network errors while closing the key or value column streams.","commonSituations":"Query cancellation closing the source before readers; double-close paths in custom page-source code; transient storage failures (HDFS/S3) at teardown.","solutions":["Close readers before the OrcDataSource; use a Closer to enforce ordering.","Ensure close() is idempotent in custom streams.","Inspect the wrapped IOException cause; treat as secondary to the original query failure.","Upgrade Presto if this matches a known double-close bug."],"exampleFix":"// before\ndataSource.close();\nmapReader.close();\n// after\ntry (Closer closer = Closer.create()) {\n    closer.register(mapReader::close);\n    closer.register(dataSource::close);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mapReader.close();\n}\ncatch (UncheckedIOException e) {\n    LOG.warn(e.getCause(), \"Failed closing map key/value stream readers\");\n}","preventionTips":["Establish close order: readers, then datasource.","Use Closer so key and value readers both close even on failure.","Never close the shared OrcDataSource while readers are active.","Make custom streams tolerate repeated close()."],"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"}