apache/seatunnel · error · IOException

Failed to close Neo4j source reader.

Error message

Failed to close Neo4j source reader.

What it means

When closing the Neo4j source reader, an exception occurred that is neither an IOException nor a RuntimeException (e.g. a checked exception from driver/session close). rethrowCloseFailure wraps it in an IOException with this message and the original as cause, so the framework's close() contract is preserved.

Source

Thrown at seatunnel-connectors-v2/connector-neo4j/src/main/java/org/apache/seatunnel/connectors/seatunnel/neo4j/source/Neo4jSourceReader.java:122

        }
    }

    private Throwable appendSuppressed(Throwable existingFailure, Throwable newFailure) {
        if (existingFailure == null) {
            return newFailure;
        }
        existingFailure.addSuppressed(newFailure);
        return existingFailure;
    }

    private void rethrowCloseFailure(Throwable throwable) throws IOException {
        if (throwable instanceof IOException) {
            throw (IOException) throwable;
        }
        if (throwable instanceof RuntimeException) {
            throw (RuntimeException) throwable;
        }
        throw new IOException("Failed to close Neo4j source reader.", throwable);
    }

    @Override
    public void internalPollNext(Collector<SeaTunnelRow> output) throws Exception {
        try {
            for (Neo4jSourceTableConfig tableConfig : tableConfigs) {
                readTable(output, tableConfig);
            }
        } finally {
            this.context.signalNoMoreElement();
        }
    }

    private void readTable(Collector<SeaTunnelRow> output, Neo4jSourceTableConfig tableConfig) {
        final Query query = new Query(tableConfig.getQuery());
        try {
            session.readTransaction(
                    tx -> {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the cause chain of the IOException for the root driver error.
  2. Verify Neo4j connectivity and that the server is not shutting down during job teardown.
  3. Upgrade the Neo4j Java driver if close() reliably throws known driver bugs.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  reader.close();
} catch (IOException e) {
  if (e.getCause() != null) log.error("Neo4j reader close root cause", e.getCause());
  // job is ending; log and continue teardown
}

Prevention

When it happens

Trigger: close() on Neo4jSourceReader fails; the underlying driver session or resources throw a checked/non-Runtime exception, which rethrowCloseFailure wraps into IOException("Failed to close Neo4j source reader.").

Common situations: Network drop to Neo4j while closing the Bolt session; driver-level resource cleanup failure at job teardown; interrupt during close.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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