{"record":{"id":"350b73d5eb8d2dbe","repo":"prestodb/presto","slug":"java-io-ioexception-wrapped-in-uncheckedioexcepti-350b73","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/SliceBatchStreamReader.java","lineNumber":162,"sourceCode":"        if (isCharType) {\n            // truncate the characters and then remove the trailing white spaces\n            return byteCountWithoutTrailingSpace(slice, offset, length, maxCodePointCount);\n        }\n        if (maxCodePointCount >= 0 && length > maxCodePointCount) {\n            return byteCount(slice, offset, length, maxCodePointCount);\n        }\n        return length;\n    }\n\n    @Override\n    public void close()\n    {\n        try (Closer closer = Closer.create()) {\n            closer.register(directReader::close);\n            closer.register(dictionaryReader::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() + dictionaryReader.getRetainedSizeInBytes();\n    }\n}\n","sourceCodeStart":144,"sourceCodeEnd":172,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/SliceBatchStreamReader.java#L144-L172","documentation":"SliceBatchStreamReader.close() delegates closing of its direct and dictionary sub-readers. If one of those throws an IOException while releasing resources, it is rethrown wrapped in an UncheckedIOException so the close() signature (no checked exceptions) is preserved.","triggerScenarios":"Calling close() on a SliceBatchStreamReader whose underlying directReader or dictionaryReader streams fail during close, e.g. because the ORC data source is already closed or an I/O error occurs on the underlying channel.","commonSituations":"Double-close of an OrcDataSource; closing readers after a query was cancelled and resources were already released; filesystem/network errors (HDFS disconnection, S3 timeouts) surfacing during cleanup.","solutions":["Inspect the wrapped IOException cause to identify the failing underlying stream or data source.","Ensure the OrcDataSource is not closed before the reader's close() is called (close in reverse order of creation).","Avoid calling close() twice; use try-with-resources so cleanup happens exactly once.","If the I/O error is transient (network filesystem), the data itself is usually already read; treat as cleanup noise and log rather than fail the query."],"exampleFix":"// before\nreader.close(); // may throw UncheckedIOException\n// after\ntry (SliceBatchStreamReader reader = createReader()) {\n    // read blocks\n} // deterministic single close via try-with-resources\n","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    reader.close();\n} catch (UncheckedIOException e) {\n    log.warn(\"Reader close failed; underlying cause: %s\", e.getCause());\n    // cleanup errors are usually non-fatal after data was read\n}","preventionTips":["Use try-with-resources so readers close exactly once and in order.","Close the OrcDataSource only after all dependent readers are closed.","Treat close-time IOExceptions as cleanup warnings unless they indicate data loss."],"tags":["orc","io","unchecked-io","resource-cleanup"],"backgroundTag":"unchecked-ioexception-on-close","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"}