apache/seatunnel · warning

Failed to close file system proxy

Error message

Failed to close {} file system proxy

What it means

A warning (not a thrown error) logged by closeFileSystemProxy in AbstractReadStrategy. When the reader shuts down it closes Hadoop FileSystem proxy objects; if proxy.close() throws any Exception, the failure is logged at WARN with the proxy's role (source/target) and execution continues — resources may leak but the job is not failed by this path.

Solutions

  1. Inspect the logged stack trace (the exception is passed as the last log argument) to identify the root close failure.
  2. Avoid sharing/closing the same Hadoop FileSystem across multiple readers; let the proxy manage its lifecycle.
  3. Ensure the filesystem (HDFS NameNode, S3 endpoint) is reachable at job teardown; transient close errors are usually safe to ignore.
  4. If leaks recur, upgrade/align Hadoop client versions used by the connector.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    proxy.close();
} catch (Exception e) {
    log.warn("Failed to close {} file system proxy", role, e);
    // non-fatal at teardown; inspect stack trace if leaks recur
}

Prevention

When it happens

Trigger: proxy.close() on a HadoopFileSystemProxy throws — typically because the underlying Hadoop FileSystem was already closed, was never fully initialized, or the close call itself hit an I/O error on the distributed filesystem.

Common situations: Job teardown after an earlier failure already closed filesystems; double-close of shared FileSystem instances; HDFS/S3 transient I/O errors during close; JVM shutdown races.

Understand the failure class

Background: "open() failed", "failed to open file", "cannot create file" — what a file open error means and how to fix it — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/c570356aeb1108f9. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/AbstractReadStrategy.java:755

                bom == null ? Charset.forName(encoding) : Charset.forName(bom.getCharsetName());
        return new BufferedReader(new InputStreamReader(bomInputStream, charset));
    }

    @Override
    public void close() throws IOException {
        if (targetHadoopFileSystemProxy != null && !shareTargetFileSystemProxy) {
            closeFileSystemProxy(targetHadoopFileSystemProxy, "target");
        }
        if (hadoopFileSystemProxy != null) {
            closeFileSystemProxy(hadoopFileSystemProxy, "source");
        }
    }

    private void closeFileSystemProxy(HadoopFileSystemProxy proxy, String role) {
        try {
            proxy.close();
        } catch (Exception e) {
            log.warn("Failed to close {} file system proxy", role, e);
        }
    }

    private void validateUpdateSyncConfig(Config pluginConfig) {
        if (!pluginConfig.hasPath(FileBaseSourceOptions.FILE_FORMAT_TYPE.key())) {
            throw new FileConnectorException(
                    SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
                    "When sync_mode=update, file_format_type must be set.");
        }
        FileFormat fileFormat =
                FileFormat.valueOf(
                        pluginConfig
                                .getString(FileBaseSourceOptions.FILE_FORMAT_TYPE.key())
                                .toUpperCase());
        if (fileFormat != FileFormat.BINARY) {
            throw new FileConnectorException(
                    SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
                    "sync_mode=update currently only supports file_format_type=binary.");

View on GitHub (pinned to cf67b549a7)