-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Integrate Apache Http client with WebClient #24700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Apache Http client with WebClient #24700
Conversation
@martin-tarjanyi Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpResponse.java
Outdated
Show resolved
Hide resolved
@martin-tarjanyi Thank you for signing the Contributor License Agreement! |
I will try and pick this up in the 5.3 timeline. |
Thank you for submitting this PR. Could you please make sure that it conforms to our Code Style? This makes it significantly easier for us to review the PR. Specifically, please make sure that there is an empty line in between class declaration and fields, and two before constructors. Please refer to other classes in the Spring Framework to see how they are formatted. |
…pache # Conflicts: # spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java
|
Great! Thanks.
Indeed, I can duplicate this issue locally. Could you please file a separate issue against Spring Framework for this problem? Not sure if the reason is in our connector or in Reactor Netty itself, but we can migrate the issue if need be.
Let's keep this as is, i.e. a new test in I am now going to take a closer look at the code, so review comments will follow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for submitting this PR.
While going through the code, I have some comments. Can you please resolve them?
...ng-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...ng-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...ng-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpConnector.java
Outdated
Show resolved
Hide resolved
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpRequest.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body) { | ||
return writeWith(Flux.from(body).flatMap(p -> p)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is supposed to flush after each inner buffer flux is complete. Is this code doing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely not, but I'm not sure. Let me tag Apache contributors @ok2c and @rschmitt maybe they can help out here.
So the question is: Is it possible to control when the reactive data producer flushes parts of the request body?
Also, folks, you are more than welcome to review this pull request if you have time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martin-tarjanyi I personally have little experience with reactive bindings but I hope @rschmitt can answer your question. What I could do though is to look at various ways of optimizing the implementation once it gets accepted.
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpRequest.java
Outdated
Show resolved
Hide resolved
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpResponse.java
Outdated
Show resolved
Hide resolved
...ng-web/src/main/java/org/springframework/http/client/reactive/MonoFutureCallbackAdapter.java
Outdated
Show resolved
Hide resolved
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpRequest.java
Outdated
Show resolved
Hide resolved
spring-web/src/main/java/org/springframework/http/client/reactive/ApacheClientHttpResponse.java
Outdated
Show resolved
Hide resolved
I've addressed most of the comments and answered where I have concerns. |
Thank you. I have some further comments and changes I'd like to see, but I do not want to ask too much of you. The code is definitely in a good enough state now for me to take over. Would you be willing to go through another round of comments? Or should I wrap it up? |
I'm happy to work on this, but if you think at this point it would be more efficient to take over then feel free to do so. Thanks for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi and thanks again,
I have left some more comments. Please help me resolve them.
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpConnector.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/springframework/http/client/reactive/HttpComponentsClientHttpRequest.java
Outdated
Show resolved
Hide resolved
This looks good, from the perspective of |
* webclient_apache: Integrate Apache http client with WebClient
This PR has now been merged. Thanks for contributing, @martin-tarjanyi! And thanks for your support, @ok2c and @rschmitt. |
This commit introduces a ClientHttpConnector implementation backed by Apache HttpComponents HttpClient 5.0. Fixes spring-projectsgh-24700
This PR aims to integrate Apache HttpClient 5 (which supports reactive streams and became GA last month) with WebClient.
Questions