prestodb/presto · error · IOException

Stream is closed

Error message

Stream is closed

What it means

Stream-state guard inside PrestoS3FileSystem's input stream: an operation was attempted after the stream had already been closed (closed flag set). The constant STREAM_IS_CLOSED makes this a sentinel IllegalStateException-style check; the fault is calling read/skip/positioning methods on a consumed stream.

Solutions

  1. Do not reuse the input stream after closing it
  2. Fix resource lifecycle so readers close exactly once, at the end
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1212 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/c342cc7d5e0f514c. Report an issue: GitHub.

Appendix: source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/s3/PrestoS3FileSystem.java:1212

            catch (Exception e) {
                throw propagate(e);
            }
        }

        private void closeStream()
        {
            if (in != null) {
                abortStream(in);
                in = null;
                STATS.connectionReleased();
            }
        }

        private void checkClosed()
                throws IOException
        {
            if (closed.get()) {
                throw new IOException(STREAM_IS_CLOSED);
            }
        }

        private static void abortStream(InputStream in)
        {
            try {
                if (in instanceof S3ObjectInputStream) {
                    ((S3ObjectInputStream) in).abort();
                }
                else {
                    in.close();
                }
            }
            catch (IOException | AbortedException ignored) {
                // thrown if the current thread is in the interrupted state
            }
        }

View on GitHub (pinned to 55bb57d202)