Add logbook-jdkhttpclient module for JDK HttpClient (#2006) - #2386
Open
Vinu2111 wants to merge 8 commits into
Open
Add logbook-jdkhttpclient module for JDK HttpClient (#2006)#2386Vinu2111 wants to merge 8 commits into
Vinu2111 wants to merge 8 commits into
Conversation
Introduce new logbook-jdkhttpclient module for JDK HttpClient (java.net.http) integration, registering it in the root POM reactor and logbook-bom.
Add TeeingBodySubscriber to capture incoming response bytes into a buffer without disturbing the delegate BodySubscriber ByteBuffer positions. Add RemoteResponse wrapping HttpResponse with lazy body buffering state machine.
Add JdkRequest implementing org.zalando.logbook.HttpRequest wrapping java.net.http.HttpRequest with lazy Flow-based body draining and request rebuilding to preserve body for transport.
Add LogbookHttpClient extending java.net.http.HttpClient with two-stage Logbook logging around send(), resilient exception handling, and full AbstractHttpTest WireMock test suite covering chunked/non-chunked bodies.
Vinu2111
requested review from
ChristianLohmann,
kasmarian,
lukasniemeier-zalando and
msdousti
as code owners
September 3, 2026 10:02
Collaborator
|
is it a duplicate of #2383? |
Contributor
Author
|
Hi @kasmarian, thanks for flagging! #2386 targets the same issue (#2006) but takes a different technical approach from #2383:
Happy to align with @ChristianLohmann on scope, or consolidate into one PR, if that's what the maintainers would prefer, just let me know which direction keeps things cleanest. |
Collaborator
|
@ChristianLohmann what do you think? |
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.
Description
Implements Phase 1 of the
logbook-jdkhttpclientmodule providing request and response logging support for JDK 11+'s built-injava.net.http.HttpClient:LogbookHttpClient: Decorator extendingjava.net.http.HttpClientthat wraps the synchronoussend()method with Logbook's two-stage request/response logging lifecycle. All abstractHttpClientgetter/delegator methods are passed through to the delegate. BothsendAsync()overloads are stubbed throwingUnsupportedOperationException(planned for follow-up).JdkRequest: Implementsorg.zalando.logbook.HttpRequestwrappingjava.net.http.HttpRequestwith a lazy body-buffering state machine (Unbuffered->Offering->Buffering/Ignoring/Passing). Drains theBodyPublisheron-demand via reactive streams and reconstructs theHttpRequestwith all original attributes (headers, method, URI, timeout, version, expectContinue) intact for transport.TeeingBodySubscriber: Decorates the responseHttpResponse.BodySubscriber<T>and tees incomingByteBuffers into a cache without mutating buffer positions or limits for the delegate subscriber.RemoteResponse: Implementsorg.zalando.logbook.HttpResponsewrappingHttpResponse<?>and cached response bytes with state machine transitions.pom.xml,logbook-bom/pom.xml, and added configuration instructions inREADME.md.Motivation and Context
Closes #2006.
Provides first-class, zero-dependency logging support for applications using Java's standard
java.net.http.HttpClientwithout requiring third-party HTTP client libraries (such as Apache HttpClient or OkHttp).Types of changes
Checklist: