{"record":{"id":"13d72baa52308034","repo":"elastic/elasticsearch","slug":"interrupted-while-waiting-for","errorCode":null,"errorMessage":"Interrupted while waiting for {}","messagePattern":"Interrupted while waiting for (.+?)","errorType":"exception","errorClass":"TestClustersException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java","lineNumber":665,"sourceCode":"                WaitForHttpResource wait = new WaitForHttpResource(\n                    httpSslEnabled ? \"https\" : \"http\",\n                    getFirstNode().getHttpSocketURI(),\n                    nodes.size()\n                );\n                if (httpSslEnabled) {\n                    getFirstNode().configureHttpWait(wait);\n                }\n                List<Map<String, String>> credentials = getFirstNode().getCredentials();\n                if (getFirstNode().getCredentials().isEmpty() == false) {\n                    wait.setUsername(credentials.get(0).get(\"useradd\"));\n                    wait.setPassword(credentials.get(0).get(\"-p\"));\n                }\n                return wait.wait(500);\n            } catch (IOException e) {\n                throw new UncheckedIOException(\"IO error while waiting cluster\", e);\n            } catch (InterruptedException e) {\n                Thread.currentThread().interrupt();\n                throw new TestClustersException(\"Interrupted while waiting for \" + this, e);\n            } catch (GeneralSecurityException e) {\n                throw new RuntimeException(\"security exception\", e);\n            }\n        });\n    }\n\n    @Nested\n    public NamedDomainObjectContainer<ElasticsearchNode> getNodes() {\n        return nodes;\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) return true;\n        if (o == null || getClass() != o.getClass()) return false;\n        ElasticsearchCluster that = (ElasticsearchCluster) o;\n        return Objects.equals(clusterName, that.clusterName) && Objects.equals(path, that.path);\n    }","sourceCodeStart":647,"sourceCodeEnd":683,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java#L647-L683","documentation":"TestClustersException thrown from the cluster-health wait when the polling thread is interrupted (InterruptedException during WaitForHttpResource.wait). The handler re-sets the interrupt flag (Thread.currentThread().interrupt()) before throwing, preserving interrupt status.","triggerScenarios":"Another thread interrupts the test thread while it is blocked in the wait condition — Gradle times out the test, a test framework cancels the task, or user-initiated cancellation.","commonSituations":"Test task timeout (--timeout or maxWorkerTimeout) fires during cluster startup; CI cancellation; a watchdog thread interrupts long-running waits.","solutions":["Check why the thread was interrupted — most often a test timeout. Raise the timeout if cluster startup is legitimately slow.","Ensure the node actually boots in a reasonable time; investigate slow startup from the node logs.","If intentional cancellation, propagate/catch InterruptedException cleanly rather than letting it surface as TestClustersException."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure adequate timeout before the wait runs\n// ./gradlew integTest --timeout 600\n// and confirm node startup is not pathologically slow via dry-run timing.","typeGuard":null,"tryCatchPattern":"try {\n    cluster.start();\n} catch (TestClustersException e) {\n    if (Thread.currentThread().isInterrupted()) {\n        // interrupt-driven; surface or handle cancellation\n        Thread.currentThread().interrupt();\n        throw e;\n    }\n    throw e;\n}","preventionTips":["Set test timeouts generously enough for cluster startup.","Investigate chronically slow startup via node logs.","Avoid cancelling tests mid-startup when feasible."],"tags":["test","testclusters","threading","interruption","wait-conditions"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}