apache/seatunnel · warning

Error while closing resource

Error message

Error while closing resource: {}

What it means

closeQuietly is a utility that closes AutoCloseable resources (connections, statements, result sets) and deliberately swallows exceptions, logging them at WARN level. This message means a resource failed to close cleanly during cleanup. It is never fatal to the pipeline; it only indicates a cleanup issue, often masking an underlying problem.

Solutions

  1. Read the logged exception message to find which resource failed and why.
  2. Check DB/network health if the message indicates connection resets.
  3. Avoid double-closing resources in your own code paths that feed closeQuietly.
  4. If noise is frequent, upgrade the Databend JDBC driver; some drivers fix close-after-failure behavior.
Defensive patterns

Strategy: try-catch

Type guard

if (resource instanceof AutoCloseable) { /* pass to closeQuietly */ }

Try / catch

try {
    doWork();
} finally {
    DatabendUtil.closeQuietly(resultSet, statement, connection); // exceptions logged, not thrown
}
// check logs for "Error while closing resource" to diagnose underlying connection issues

Prevention

When it happens

Trigger: Any call to DatabentUtil.closeQuietly where closeable.close() throws — e.g. closing an already-closed connection, a socket broken by network loss, or a driver throwing on close after a prior error.

Common situations: Job teardown after an upstream failure; DB connection reset by peer; driver-specific close errors; double-close in error paths.

Related errors


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

Appendix: source

Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/util/DatabendUtil.java:340

        List<String> columns = new ArrayList<>();
        try (PreparedStatement statement = connection.prepareStatement(sql.toString());
                ResultSet resultSet = statement.executeQuery()) {
            while (resultSet.next()) {
                columns.add(resultSet.getString("column_name"));
            }
        }
        return columns;
    }

    /** Close resources quietly */
    public static void closeQuietly(AutoCloseable... closeables) {
        for (AutoCloseable closeable : closeables) {
            if (closeable != null) {
                try {
                    closeable.close();
                } catch (Exception e) {
                    log.warn("Error while closing resource: {}", e.getMessage());
                }
            }
        }
    }
}

View on GitHub (pinned to cf67b549a7)