{"record":{"id":"86627ab671084e57","repo":"prestodb/presto","slug":"java-io-ioexception-wrapped-in-uncheckedioexcepti","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/ListBatchStreamReader.java","lineNumber":215,"sourceCode":"        elementStreamReader.startRowGroup(dataStreamSources);\n    }\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(elementStreamReader::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 + elementStreamReader.getRetainedSizeInBytes();\n    }\n}\n","sourceCodeStart":197,"sourceCodeEnd":225,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/ListBatchStreamReader.java#L197-L225","documentation":"ListBatchStreamReader.close registers elementStreamReader::close with a Guava Closer; if the nested element stream reader's close throws IOException, Closer rethrows it and the wrapper converts it to UncheckedIOException. This signals that closing the nested list-element reader failed — typically an underlying IO problem while finishing reads, though for most in-memory streams close failures are rare.","triggerScenarios":"Calling close() (explicitly or via try-with-resources on the ORC page source) when elementStreamReader.close() throws IOException.","commonSituations":"Underlying OrcDataSource already closed or failed (disk error, remote read failure); exceptions raised during error-path cleanup (close called while handling a prior read failure); resource issues on the storage layer.","solutions":["Inspect the cause of the UncheckedIOException for the real storage-layer failure and address it (disk, network, permissions).","Ensure the whole read pipeline uses try-with-resources so close failures surface in context.","If close fails during exception handling, log it as suppressed rather than masking the primary error.","Check the remote/filesystem health if reading from HDFS/S3; retry the read after the storage issue is resolved."],"exampleFix":"// before\nreader.close(); // UncheckedIOException surfaces raw\n// after\ntry {\n    reader.close();\n}\ncatch (UncheckedIOException e) {\n    log.warn(\"Failed to close ORC reader cleanly: %s\", e.getCause());\n    // do not let cleanup failures mask the original read error\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try (OrcReader reader = openReader(file)) {\n    return reader.readAll();\n} catch (UncheckedIOException e) {\n    log.warn(\"ORC reader close failed\", e.getCause());\n    throw e; // or handle storage-layer cause\n}","preventionTips":["Always close readers with try-with-resources so cleanup is ordered.","Check the UncheckedIOException cause for the real storage failure.","Avoid calling close() twice; rely on try-with-resources idempotence.","Investigate disk/network health if close failures recur."],"tags":["io","resource-cleanup","unchecked-ioexception","orc"],"backgroundTag":"stream-close-ioexception","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"}