Repository navigation
fix: complete waiting HTTP requests after connection failures - #23
Open
Hanabi9248 wants to merge 1 commit into
Open
Hanabi9248 wants to merge 1 commit into
Hanabi9248 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.