jruby/jruby · error · IllegalStateException

file already closed

Error message

file already closed

What it means

Error "file already closed" thrown in jruby/jruby.

Source

Thrown at core/src/main/java/org/jruby/ext/ffi/io/FileDescriptorByteChannel.java:122

    /**
     * Tests if the ByteChannel is open.
     *
     * @return <code>true</code> if the Channel is still open
     */
    public boolean isOpen() {
        return isOpen;
    }
    /**
     * Closes the <code>Channel</code>.
     * <p>
     * This closes the underlying native file descriptor.
     * </p>
     * @throws java.io.IOException
     */
    public void close() throws IOException {
        if (!isOpen) {
            throw new IllegalStateException("file already closed");
        }
        isOpen = false;
        libc.close(fd);
    }
}

View on GitHub (pinned to fb650c13e0)

Solutions

  1. The underlying file descriptor was already closed. Reorder close operations or guard against double-close so the channel is not used after the descriptor is gone.

When it happens

Trigger: Thrown at core/src/main/java/org/jruby/ext/ffi/io/FileDescriptorByteChannel.java:122 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jruby/jruby@fb650c13e0 (2026-08-23). Data as JSON: /api/errors/a3e7175fb627af15. Report an issue: GitHub.