Skip to content

fix: complete waiting HTTP requests after connection failures - #23

Open
Hanabi9248 wants to merge 1 commit into
IvorySQL:IVYC_REL_5_STABLEfrom
Hanabi9248:codex/http-async-failure-completion
Open

Hanabi9248 wants to merge 1 commit into
IvorySQL:IVYC_REL_5_STABLEfrom
Hanabi9248:codex/http-async-failure-completion

Conversation

@Hanabi9248

Copy link
Copy Markdown

HttpUtils.builder().url(...).get().async() prepares an error response in OkHttp's onFailure callback, but never releases the semaphore awaited by its caller. A completed connection failure therefore leaves the method blocked. The successful-response callback already releases it.

Add the same release after the existing failure text is built. This one-line production change keeps the current return format, success path, callback overload, client configuration and semaphore ownership model. This is a public utility contract; no application invocation or deployed incident was found in the inspected source.

The new regression compiles the complete production class and calls its real builder with real OkHttp against loopback sockets and a JDK HttpServer. Refused connections and a server disconnect before headers both reach the original failure callback, yet the baseline caller remains blocked until its private eight-second test watchdog interrupts it. The returned failure text confirms the callback ran; an inconclusive transport timeout is rejected. Both success controls pass. With the fix all four cases pass, with zero skips. The watchdog is test-only; no production timeout is added. Reflection retrieves the real client only for cleanup, and no client, callback, logger or semaphore is replaced.

Main validated serially on Windows/JDK25.0.4.101 with javac --release 8, real cached OkHttp4.12.0, Okio3.6.0, Kotlin1.9.25, Jackson2.11.3, SLF4J1.7.30 and Lombok1.18.42. SLF4J used its standard NOP fallback. The project-declared OkHttp4.9.3/Lombok1.18.20 and JDK8 runtime were not tested; no POM or dependency changed. CPU1, whole-job768MiB/16 processes, private TMP and BLAS1; peak197758976 bytes. Source CRLF bytes are preserved.

Compile HttpUtils.java and tests/regression/HttpAsyncFailureRegression.java with the real jars on the classpath and Lombok processor path, then run java --add-modules jdk.httpserver -cp <classes-and-real-dependencies> HttpAsyncFailureRegression. Full Maven/backend, Linux, Internet/TLS, concurrent/shared-semaphore behavior and response-body-read exceptions were not tested. Codex0.165.0-alpha.1.2 assisted implementation and validation; contributor sign-off is included.

Release the existing semaphore after HttpUtils.async() prepares its
failure response, matching the successful-response path. Otherwise a
completed OkHttp failure leaves the public caller blocked indefinitely.

Cover refused loopback connections, disconnects before HTTP headers,
and successful async/sync requests using the complete production class
and real OkHttp networking.

Assisted-by: Codex 0.165.0-alpha.1.2
Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant