{"record":{"id":"7977d7c689c2f3c8","repo":"apache/seatunnel","slug":"interrupted-during-edge-transport-open","errorCode":null,"errorMessage":"Interrupted during edge transport open","messagePattern":"Interrupted during edge transport open","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"warning","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/socket/EdgeTransportClient.java","lineNumber":71,"sourceCode":"    }\n\n    EdgeTransportClient(EdgeTransportConfig config, EdgeSocketSocketFactory socketFactory) {\n        this.config = Objects.requireNonNull(config, \"config\");\n        this.socketFactory = Objects.requireNonNull(socketFactory, \"socketFactory\");\n        this.lineTransport = new EdgeSocketLineTransport(config);\n        this.endpoint = EdgeTransportEndpoints.toSocketAddress(config.getEndpoint());\n    }\n\n    @Override\n    public void open() {\n        synchronized (connectionLock) {\n            try {\n                ensureAuthenticatedSession();\n            } catch (IOException ex) {\n                throw new UncheckedIOException(ex);\n            } catch (InterruptedException ex) {\n                Thread.currentThread().interrupt();\n                throw new IllegalStateException(\"Interrupted during edge transport open\", ex);\n            }\n        }\n    }\n\n    @Override\n    public void send(long batchId, String payload) throws IOException, InterruptedException {\n        sendUntilReceived(batchId, payload);\n    }\n\n    @Override\n    public void sendUntilReceived(long batchId, String payload)\n            throws IOException, InterruptedException {\n        synchronized (connectionLock) {\n            IOException lastIo = null;\n            InterruptedException lastInterrupted = null;\n            for (int cycle = 0; cycle < config.getMaxReconnectCycles(); cycle++) {\n                try {\n                    ensureAuthenticatedSession();","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/socket/EdgeTransportClient.java#L53-L89","documentation":"EdgeTransportClient.open ensures an authenticated session before sending; while doing so it may block (sleeping/backoff) and can be interrupted. On InterruptedException it restores the thread's interrupt flag and throws this IllegalStateException — the open was aborted because the calling thread was interrupted, not because of a network problem.","triggerScenarios":"Another thread calls Thread.interrupt() on the thread inside EdgeTransportClient.open() while ensureAuthenticatedSession() is sleeping or retrying (e.g. job cancellation, shutdown hook, executor shutdownNow).","commonSituations":"Agent shutdown while a client is lazily connecting; a scheduled task cancelled mid-connect; thread pool shutdownNow() during deploy; watchdog interrupting a stuck connect.","solutions":["Investigate who interrupts the thread (shutdown/cancellation path) and ensure clients are closed before the executor shuts down","Check the interrupt flag handling in your job lifecycle: stop scheduling sends after shutdown is initiated","If interruption is expected (shutdown), catch IllegalStateException and treat open as aborted","Retry opening the client on a fresh thread if the interruption was spurious"],"exampleFix":"// before\nexecutor.shutdownNow(); // interrupts in-flight open()\n// after\nclient.close();\nexecutor.shutdown();\nexecutor.awaitTermination(30, TimeUnit.SECONDS);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { client.open(); } catch (IllegalStateException e) { if (e.getMessage().contains(\"Interrupted\")) { log.info(\"open aborted by interruption, not retrying\"); return; } throw e; }","preventionTips":["Close clients and cancel in-flight opens before executor.shutdownNow()","Check Thread.interrupted() status before starting long connect sequences","Use cooperative shutdown (flags) instead of interrupts where possible","Keep connect blocking time short so interrupts are rare"],"tags":["interruption","concurrency","lifecycle"],"backgroundTag":"thread-interrupted","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}