{"record":{"id":"db2123e41d050cfb","repo":"eclipse-vertx/vert.x","slug":"result-is-already-complete","errorCode":null,"errorMessage":"Result is already complete","messagePattern":"Result is already complete","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"info","filePath":"vertx-core/src/main/java/io/vertx/core/Promise.java","lineNumber":76,"sourceCode":"  default void complete(T result, Throwable failure) {\n    if (failure == null) {\n      succeed(result);\n    } else {\n      fail(failure);\n    }\n  }\n\n  /**\n   * Set the result. Any handler will be called, if there is one, and the promise will be marked as completed.\n   * <p/>\n   * Any handler set on the associated promise will be called.\n   *\n   * @param result  the result\n   * @throws IllegalStateException when the promise is already completed\n   */\n  default void complete(T result) {\n    if (!tryComplete(result)) {\n      throw new IllegalStateException(\"Result is already complete\");\n    }\n  }\n\n  /**\n   * Calls {@code complete(null)}\n   *\n   * @throws IllegalStateException when the promise is already completed\n   */\n  default void complete() {\n    if (!tryComplete(null)) {\n      throw new IllegalStateException(\"Promise already completed\");\n    }\n  }\n\n  default void succeed(T result) {\n    if (!tryComplete(result)) {\n      throw new IllegalStateException(\"Promise already completed\");\n    }","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/Promise.java#L58-L94","documentation":"SC_GATEWAY_TIMEOUT is an HttpResponseExpectation constant asserting an HTTP 504 status. When used as a client expectation it fails any response whose status is not exactly 504, reporting '504 Gateway Timeout'.","triggerScenarios":"Applying request.expect(HttpResponseExpectation.SC_GATEWAY_TIMEOUT) to a response with a different status; matching responses where an upstream gateway/proxy timed out.","commonSituations":"Upstream service latency exceeded the proxy timeout in production; load tests deliberately provoking gateway timeouts; asserting timeout semantics in proxy integration tests.","solutions":["Increase upstream processing performance or gateway/proxy timeout settings so requests complete in time.","Add client-side timeouts and retries with backoff for idempotent requests.","If 504 is the intended contract (timeout tests), keep SC_GATEWAY_TIMEOUT and ensure the proxy timeout is shorter than the client timeout."],"exampleFix":"// before\nrequest.expect(HttpResponseExpectation.SC_GATEWAY_TIMEOUT).send();\n// after\nrequest.expect(HttpResponseExpectation.status(200)).send();","handlingStrategy":"retry","validationCode":"long started = System.nanoTime();\nif (response.statusCode() == 504) { /* upstream timeout: back off and retry idempotent ops */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size gateway timeouts above realistic upstream p99 latency.","Set explicit client timeouts shorter than the gateway's so the client fails first.","Load-test slow endpoints before production."],"tags":["http","timeout","gateway","expectation"],"backgroundTag":"request-timeout","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}